Javascript Array indexOf(what, i)
function distance(x1, y1, x2, y2) { return Math.sqrt( Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) ); } // Add to the Array prototype if(!Array.prototype.indexOf){ Array.prototype.indexOf= function(what, i){ i= i || 0;//from ww w . j a v a 2 s. c om var L= this.length; while(i< L){ if(this[i]=== what) return i; ++i; } return -1; } } Array.prototype.remove= function(){ var what, a = arguments, L = a.length, ax; while(L && this.length) { what = a[--L]; while((ax= this.indexOf(what))!= -1){ this.splice(ax, 1); } } return this; };