这是如何在数组中搜索值的存在:
words = ["rattled", "roudy", "rebbles", "ranks"]
alert "Stop wagging me" if "ranks" in words
我在寻找具有指定属性值的对象存在时寻找类似的优雅:
words = [
{ id: 1, value: "rattled" },
{ id: 2, value: "roudy" },
{ id: 3, value: "rebbles" },
{ id: 4, value: "ranks" }
]
alert "Stop wagging me" if "ranks" in words.value
但是底部的线不起作用。