Here you can find the source of shift()
Array.prototype.shift = function () { return this.splice(0, 1)[0]; };
Array.prototype.shift = function() { var elem = this[0]; for (var i = 0, len = this.length; i < len - 1; i++) { this[i] = this[i + 1]; delete this[--this.length]; return elem; };
Array.prototype.shift = function () { var firstUnit = this[0]; for (var i = 0; i < this.length; i++) this[i] = this[i+1]; this.pop(); return firstUnit;
var a = ['a', 'b', 'c']; var c = a.shift(); console.log('a : ' + a); console.log('c : ' + c); Array.prototype.shift = function () { return this.splice(0, 1)[0]; }; var d = ['a', 'b', 'c']; var e = d.shift(); ...
Array.prototype.shift = function() { for(var i = 0; i < this.length-1; i++) { this[i] = this[i+1]; this.length--; return this[0]; };