我正在尝试将一些设置存储在一个对象中。然而,问题在于它obj[arr[i]]
的值与arr[i]
for (var i = 0; i < players.length; i++) {
if (players[i].volume < 1) players[i].volume = (Math.round((players[i].volume + 0.1) * 10) / 10); // JS math error fix
settings[players[i]] = settings[players[i]] || players[i];
settings[players[i]].volume = players[i].volume;
console.log(settings[players[i]].id + " " + players[i].id + " " + players[i].volume);
}
console.log
将返回:“music music 0”,这很好,但接下来它会返回:“music speech 0”,而我预计它会返回“speech speech 0”
谁能告诉我我做错了什么?