假设我的json对象是这样的
var User: {"phone": {"key1": "value", "key2": "value"}}
然后,我要删除key1属性,用下面代码就能删除
key1
delete User.phone.key1;
但是,当我要删除的key是个传入的变量,下面这段代码就不管用了
var type = "key1"; delete User.phone.type;
这是为什么呢?
ITMISS
相关分类