Javascript Array unshift(elem)

Description

Javascript Array unshift(elem)


Array.prototype.unshift = function(elem) {
  for (var i = this.length; i > 0; i--) {
    this[i] = this[i - 1];/* w ww. j a  v  a 2  s  .co  m*/
  }
  this[0] = elem;
  
  return ++this.length;
};



PreviousNext

Related