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...
}
}
Wenn ich so sortiere. console.log funktioniert gut. Aber wenn der Satz nicht funktioniert. Ich erhalte eine Fehlermeldung. Ich weiß nicht warum. Bitte hilf mir.Zugriff Eigenschaft in node.js
if(PLAYER_LIST[sorted[loop]].team == "A") {
^
TypeError: Cannot set property 'team' of undefined
vielen Dank !!!!!!! – firepunch
mein schrecklicher Fehler .. :( – firepunch