对于一个普通的js对象:
var obj = { name:"mary", age:21 }
如果我们要对它添加新属性的话可以使用下列方式:
obj.address = "北京" //{name: "mary", age: "21", address: "beijing"}
删除属性,需要使用delete方法:
delete obj.name //{age: "21", address: "beijing"}
欲当凌绝顶,一览众山小。
原文地址:https://www.cnblogs.com/DZzzz/p/9847639.html
时间: 2024-10-13 16:54:53