0

私はこれに問題があります。

//Targeting a property of an object using an array

myArray = ["property0","property1","property2","property3"];

myObject = {};

myObject[myArray[0]] = "value0";
//accepts this line as myObject.property0 = "value0";  

alert(myObject.myArray[0]);  // <-- how can I target this using my Array?
//this fails

// alert(myObject.property0); 
//this works
4

1 に答える 1

1

同じように設定します:

alert(myObject[myArray[0]])
于 2012-10-26T17:01:04.563 に答える