You would iterate inside the object with a for loop:(您将使用for循环在对象内部进行迭代:)
for(var i in foo){
alert(i); // alerts key
alert(foo[i]); //alerts key's value
}
Or(要么)
Object.keys(foo)
.forEach(function eachKey(key) {
alert(key); // alerts key
alert(foo[key]); // alerts value
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…