Created
April 23, 2010 19:07
-
-
Save dshaw/377011 to your computer and use it in GitHub Desktop.
Array.prototype.remove( element )
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
// Check to make sure indexOf is implemented (!!IE6). | |
if (!Array.indexOf) { | |
Array.prototype.indexOf = function(elem) { | |
var i=0, | |
length=this.length; | |
for (; i < length; i++) { | |
if (this[i] === elem ) { | |
return i; | |
} | |
} | |
return -1; | |
}; | |
} | |
// Add remove method to Array. | |
Array.prototype.remove = function(elem) { | |
return this.splice(this.indexOf(elem), 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment