1 /* 2 判断数组中是否存在 3 var somearray = ["mon", "tue", "wed", "thur"] 4 somearray.exists ("tue"); 5 //somearray will return true 6 */ 7 Array.prototype.exists = function (val) { 8 for (var i = 0; i < this.length; i++) { 9 if (this[i] == val) { 10 return true; 11 } 12 } 13 return false; 14 }