JS 空对象内插入对象

 

 1 let Obj = {}
 2 
 3 let ID = "cd4fg62sd4gasg4nsetjmu"
 4 let ID2 = "a3526d8hs56df5sd5df45d"
 5 
 6 let Res = {
 7     name:"阿西吧",
 8     lv:666
 9 }
10 let Res2 = {
11     name:"阿西吧",
12     lv:666
13 }
14 
15 
16 let TempVar = {}
17 TempVar[ID] = Res
18 
19 TempVar
20 //TempVar{
21 //  cd4fg62sd4gasg4nsetjmu{
22 //      lv: 666
23 //      name: "阿西吧"
24 //  }
25 //}
26 
27 Obj.SuiBianSha = TempVar
28 
29 Obj.SuiBianSha[ID2] = Res2
30 
31 Obj
32 //Obj{
33 //  SuiBianSha{
34 //      a3526d8hs56df5sd5df45d{
35 //          lv: 666
36 //          name: "阿西吧"
37 //      },
38 //      cd4fg62sd4gasg4nsetjmu{
39 //          lv: 666
40 //          name: "阿西吧"
41 //      }
42 //}

 

你可能感兴趣的:(JS 空对象内插入对象)