0
我定義(只是舉例)三個變量如下:jQuery的添加變量到另一個變量名動態
window.myCirclePlayer_0 = ...
window.myCirclePlayer_1 = ...
window.myCirclePlayer_2 = ...
別的地方在我的代碼(假性碼):
var index = 0 1 or 2; //index can be 0, 1 or 2, we don't know which yet
然後我想要將索引添加到窗口變量,以便它調用正確的方法。這雖然不起作用。這是甚麼可能嗎?
window.myCirclePlayer_[index].doMethod();
輝煌。謝謝。 –