javascript的数组有没有像java中list的.contains()这种方法,不用循环判断出数组里有没有对象?
急!!!!!!!!!!!!!!!!!
------解决方案--------------------
//参考一下:
Array.prototype.contains = function(str)
{
for (var i = 0; i < this.length; i++)
{
if (this[i] == str)
return true;
}
return false;
}
var arr = new Array( "aa ", "bb ", "cc ");
alert(arr.contains( "aa "));