javascript がこのタイプのエラーを返すのはなぜですか:
TypeError: Cannot use 'in' operator to search for 'active' in undefined
私がこのようなことをするとき
foo = [
{link:"http1", active:"true"},
{link:"http2", active:"true"},
{link:"http3"}
]
var checker = function(){
for(i=0; i<= foo.length; i++){
if('active' in foo[i]){
checked = true
}
}
}
しかし、同じ foo オブジェクトを使用してコンソールでこれを行うと
'active' in foo[0]
それはtrueを返しますか?