Arrays 在Flex中,测试Flex中包含特定值的数组

Arrays 在Flex中,测试Flex中包含特定值的数组,arrays,apache-flex,Arrays,Apache Flex,我有一个数组,里面有很多值。我只是想要一种简单而好的方法来检查数组是否包含特定的值。 提前感谢。像这样使用: if (myArray.indexOf(item) != -1) trace("item exists"); else trace("nope! can't find it") 如果项存在,indexOf返回索引;如果不存在,则返回-1。if(myArray.indexOf(“”

我有一个数组,里面有很多值。我只是想要一种简单而好的方法来检查数组是否包含特定的值。 提前感谢。

像这样使用:

if (myArray.indexOf(item) != -1) trace("item exists");
else trace("nope! can't find it")
如果项存在,indexOf返回索引;如果不存在,则返回-1。

if(myArray.indexOf(“”<0)//此处编码(如果找不到值,则返回-1)
if(myArray.indexOf("<searchObject>") < 0) //Code here (returns -1 if the value isn't found) 
{ 
    //the value isn't found
} else
{ 
    //the value is found
}
{ //找不到该值 }否则 { //找到该值 }
这太奇怪了。你问了这个问题。里亚斯塔回答了。然后你认为对他的答案做不必要的修改是合适的,自己回答问题而不是接受他的答案?!