javascript对象动态设置?

时间:2016-12-21 20:33:03

标签: javascript

如何动态设置theName并进行更改?有没有办法做到这一点?

var myTeam = new Object ();

 function AddObject(theName) {

   var person = new Object();
   person.firstName = "John";
   person.lastName = "Doe";
   person.age = 50;
   person.eyeColor = "blue";

  myTeam.theName =  person;
}

AddObject("Example1");
AddObject("Example2");
AddObject("Example3");

0 个答案:

没有答案