Javascript Array indexOf(item)
Array.prototype.indexOf = function(item){ for (var i = 0; i < this.length; i++) { if(this[i] === item) return i; };/*from w w w . ja v a2s . c om*/ return -1; };
/**/*from w w w.j a va 2 s . c o m*/ * gets the index of an element in the array. returns -1 if the item is not present * * @param item - item to look for */ Array.prototype.indexOf = function(item) { return _indexOf(this, item); }
Array.prototype.indexof=function(item){ var arr=[];/* w w w .java2s . c o m*/ for(var i=0;i<arr.length;i++){ if(arr[i]==item){ arr.push(i); } } return arr; }
Array.prototype.indexOf = function(item) { for (var i = 0; i < this.length; i++) { if (this[i] === item) { return i;/*from ww w.ja va 2s . c o m*/ } } return -1; }