Skip to content

Instantly share code, notes, and snippets.

@davidrautert
Created November 8, 2011 20:02
Show Gist options
  • Save davidrautert/1348979 to your computer and use it in GitHub Desktop.
Save davidrautert/1348979 to your computer and use it in GitHub Desktop.
js prototype of unshift function
if(!Array.prototype.unshift) { // if this method does not exist..
Array.prototype.unshift = function(){
this.reverse();
for(var i=arguments.length-1;i>=0;i--){
this[this.length]=arguments[i]
}
this.reverse();
return this.length
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment