以下をより効率的にするにはどうすればよいですか?:
var varToChange = ['playerList',24,'hp',24];
//Sending that info to the client...
if(varToChange.length == 2){
window[varToChange[0]] = varToChange[1]
}
...
if(varToChange.length == 4){
window[varToChange[0]][varToChange[1]][varToChange[2]][varToChange[3]] = varToChange[4]
}