PHP's Array function In_array () is very convenient, but JS is not. In fact, I really do not like the JS array ~
Stop it, go straight to the method.
Array.prototype.in_array = function (e) {for (i=0;i<this.length;i++) {if (this[i] = = e) return true;} return false;}
Or
Array.prototype.in_array = function (e) {for (i=0;i<this.length && this[i]!=e;i++); return! ( I==this.length); }
Both of these are possible. is actually a form, the wording is not the same.
Of course, there is one more way I would recommend,
Array.prototype.s=string.fromcharcode (2); Array.prototype.in_array=function (e) {var r=new RegExp (this. S+e+this. S); Return (R.test (this. S+this.join (this. S) +this. S)); }
I personally like this, do not understand the relationship, you just use my code to write a good, Gaga.
Test the analog data.
var aa = new Array (, ' AA ', ' BBB ', 4,5); Alert (Aa.in_array (3)); Alert (Aa.in_array (' AA '));