Javascript Array myUnshift(val)

Description

Javascript Array myUnshift(val)


'use strict';/*from   ww w.j  a v a 2s.  c om*/

Array.prototype.myUnshift = function(val){
  for(var i = this.length-1; i >= 0; i--){
    this[i+1] = this[i];
  }
  this[0] = val;
  return this.length;
}



PreviousNext

Related