List of utility methods to do Array Unshift
unshift()Array.prototype.unshift = function(){ [].splice.apply(this, [0, 0].concat([].slice.apply(arguments))); return this.length; }; | |
unshift(data)Array.prototype.unshift = function(data) { for(var i = this.length; i > 0; i--) { this[i] = this[i-1]; this[0] = data; return this.length; }; | |
unshift(elem)Array.prototype.unshift = function(elem) { for (var i = this.length; i > 0; i--) { this[i] = this[i - 1]; this[0] = elem; return ++this.length; }; | |
unshiftMe(num)Array.prototype.unshiftMe = function (num) { this[this.length] = this[this.length-1]; for (var i = this.length-1; i >= 1; i--) { this[i] = this[i-1]; this[0] = num; return this.length; | |
unshiftRange(arr)Array.prototype.unshiftRange = function(arr) {
this.unshift.apply(this, arr);
};
|