Created
November 8, 2011 20:02
-
-
Save davidrautert/1348979 to your computer and use it in GitHub Desktop.
js prototype of unshift function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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