Add:
Let name=" XXX "let obj = {"age": 21}; obj.name = "xxx2"; / / now obj is / / {" age ": 21," name ":" xxx2} / / [] to increase the let obj2 = {" phone ":" iphone "}; obj2["num"]= 3; let name = "name2"; Obj2 [name] = "I is XXX" now / / / / by variable obj2 for / / {" phone ":" iphone ", "num" : 3, name2: "XXX"}Copy the code
Modification:
Obj = {"age": 21, "name": "XXX"}; Boj. Name = "my name "; {"age": 21, "name": "my name"}; Obj ['age'] = 18; {"age": 18, "name": "my name"}Copy the code
Object computed properties:
let name="xxxxx",
let obj={name:name,[name]:name};
得到结果:
// obj={name:"xxxxx",xxxxx:"xxxxx"}
Copy the code