0
我遇到了一個問題,試圖查看一個值是否與包含一個對象的數組相匹配。查找對象內的值 - jQuery
下面是我在做什麼:
var found = $.inArray(opt.ifpo_width, selectedOptions) > -1;
比方說opt.ifpo.width
包含650
。 selectedOptions
包含一個值爲650
的對象,因此我希望found
返回0,因爲這意味着該值已找到。
繼承人的selectedOptions
console.log
一個例子:
[Object, Object]
0: Object
active: true
......
ifpo_width: "650" <-- value I am checking
ifpo_x: "153"
ifpo_y: "86"
shown: false
__proto__: Object
1: Object
active: true
ifpo_width: "650" <-- this other object should not be here because there is already a width of the same value.
ifpo_x: "140"
ifpo_y: "102"
.....
你有什麼建議和如何我可以檢查此selectedOptions
的價值與opt.ifpo_width
被檢查的想法?