Javascript Array indexFor( item )
Array.prototype.indexFor = function( item ) { var output=-1; for (var i = 0 ; i < this.length ; i ++) { if (this[i]===item) { output= i; /*from w ww .j ava2 s . c om*/ break; } } return output; }; [2,3,5,5,6,8,9,10,22,49].indexFor("a");