Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:06
Show Gist options
  • Save st98/8ab15fb764c0b6d644fa to your computer and use it in GitHub Desktop.
Save st98/8ab15fb764c0b6d644fa to your computer and use it in GitHub Desktop.
Array#shift。
Object.defineProperty(Array.prototype, 'shift', {
value: function (n) {
return this.slice(n).concat(this.slice(0, n));
},
enumerable: false,
configurable: true,
writable: false
});
//-----
var _slice = Array.prototype.slice;
function shift(array, n) {
return _slice.call(array, n).concat(_slice.call(array, 0, n));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment