//判断数组中是否存在某字符串
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));
};
?
用法:
????var arr = [‘a‘,‘b‘,‘c‘];
??? arr.in_array("a");//返回值为true或false。存在为true,不存在为false。
原文:http://lafecat.iteye.com/blog/2275272