Array.prototype.unshift
Sunny-117 opened this issue · comments
Sunny commented
Array.prototype.myUnshift = function (...items) {
this.reverse().push(...items.reverse())
this.reverse()
return this.length
}
kangkang123269 commented
Array.prototype.unshift = function() {
var itemsToAdd = arguments.length;
var len = this.length;
for (var i = len - 1; i >= 0; i--) {
this[i + itemsToAdd] = this[i];
}
for (var j = 0; j < itemsToAdd; j++) {
this[j] = arguments[j];
}
return this.length;
};