【发布时间】:2015-12-18 20:39:18
【问题描述】:
for(j=0;j<twitchUserArray.length;j++)
{
displayALL(twitchUserArray[j]);
}
function displayALL(person){
console.log("Inside displayALL");
console.log(person);
console.log(person.logo);
}
数组[9]
0:对象
game: ""
logo: "http: //static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_image-f1b681380c0b0380-300x300 .png"
name: "freecodecamp"
status: null
twitchfeed: "http: //www.twitch.tv/freecodecamp"
__proto__: Object
1:对象
game: ""
logo: "http: //static-cdn.jtvnw.net/jtv_user_pictures/storbeck-profile_image-7ab13c2f781b601d-300x300 .jpeg"
name: "storbeck"
status: null
twitchfeed: "http: //www.twitch.tv/storbeck"
__proto__: Object
2:对象
game: ""
logo: null
name: "terakilobyte"
status: null
twitchfeed: "http: //www.twitch.tv/terakilobyte"
__proto__: Object
谁能告诉我在 displayALL 函数中获取键值的正确语法。该 for 循环中的每个索引都是一个对象。 Console.log(person) 在 chrome 中进行故障排除时向我显示包含所有键和值的对象,但我已经尝试过。表示法和方括号表示法,除了未定义之外什么都得不到
【问题讨论】:
-
codepen.io/RawleJuglal/pen/VeaKYm 这是 codepen,如果你想看的话。谢谢。
-
您需要向我们展示该数组中的内容。
-
OK,添加了数组的前三个。将每个索引显示为单独的索引以及其中的内容。所有 9 个都有相同的键。感谢您的关注。