Array Empty Element to remove in javascript using prototype

by Prabakaran 2012-07-30 10:32:38

<script type="text/javascript">
//Method I
Array.prototype.clean = function(deleteValue) {
for (var i = 0; i < this.length; i++) {
if (this[i] == deleteValue) {
this.splice(i, 1);
i--;
}
}
return this;
};

test = new Array("","One","Two","", "Three","","Four").clean("");
test2 = [1,2,,3,,3,,,,,,4,,4,,5,,6,,,,];
test2.clean(undefined);


</script>
842
like
0
dislike
0
mail
flag

You must LOGIN to add comments