Created
July 6, 2012 01:46
-
-
Save luokebi/3057531 to your computer and use it in GitHub Desktop.
delete a item in a indexed array
This file contains 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
//delete a item in indexed array | |
Array.prototype.remove=function(dx) | |
{ | |
if(isNaN(dx)||dx>this.length){return false;} | |
for(var i=0,n=0;i<this.length;i++) | |
{ | |
if(this[i]!=this[dx]) | |
{ | |
this[n++]=this[i] | |
} | |
} | |
this.length-=1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment