Javascript Array inArray(needle) method
Array.prototype.inArray = function(needle) { for(var i=0; i < this.length; i++) { if(this[i] === needle) { return true; }/*from www. ja v a 2s . co m*/ } return false; }
Array.prototype.inArray=function(needle){ for(var i=0;i<this.length;i++){ if(this[i]===needle){ return true; }/*w w w . ja v a2 s. c o m*/ } return false; } var arr=["red","blue","yellow"]; console.log(arr.inArray("blue"));