我有一个数组,其中有很多值。我只是想要一个简单而好的方法来检查数组是否包含特定值。 提前致谢。
最佳答案
使用Array.indexOf()像这样:
if (myArray.indexOf(item) != -1) trace("item exists");
else trace("nope! can't find it")
indexOf 如果该项目存在则返回索引,如果不存在则返回 -1。
关于arrays - 在 Flex 中,测试数组是否包含 flex 中的某个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11032495/