Home > Article > Web Front-end > Js method to dynamically add and delete object properties
var obj = {} 或 var obj = new Object() //1.对象.属性 = 赋值 obj.aaa = 1 //2.对象[属性] = 赋值 obj["aaa"] = 1; 方法2中的属性可以为变量,例如 var a = "aaa"; obj[a] = 1; ==================== 删除 delete obj.aaa delete obj["aaa"]
The above is the detailed content of Js method to dynamically add and delete object properties. For more information, please follow other related articles on the PHP Chinese website!