Array.indexOf Fix //JavaScript Function
Join the DZone community and get the full member experience.
Join For FreeJust an idiot fix to increase the number of my posts =b
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com
[].indexOf || (Array.prototype.indexOf = function(v){
for(var i = this.length; i-- && this[i] !== v;);
return i;
});
example
var x = [0,1,2,3];
alert(x.indexOf(2));
alert(x.indexOf(4));
Opinions expressed by DZone contributors are their own.
Comments