js为一个对象Object添加一个新的属性和值
1,
var obj = {}; //或者 var obj=new Object(); var key = "name"; var value = "张三丰" obj[key] = value;
2,
var obj = {}; var key = "name"; var value = "张三丰" eval("obj.p" + key + "='" + value + "'");
原地址:https://blog.csdn.net/u011127019/article/details/59112030/