-1
sorted = Object.keys(PLAYER_LIST).sort(function(a,b){return a.score - b.score}); // have key value
console.log(PLAYER_LIST[sorted[0]].team); // result:"A"
for(var loop=0; loop<=sorted.length; loop++) {
if(PLAYER_LIST[sorted[loop]].team == "A") { // error
some code...
}
}
当我这样排序。 console.log运行良好。但是如果判决不起作用。我收到错误消息。我不知道为什么。请帮帮我。在node.js访问属性
if(PLAYER_LIST[sorted[loop]].team == "A") {
^
TypeError: Cannot set property 'team' of undefined
太感谢你了!!!!!!! – firepunch
我可怕的错误.. :( – firepunch