js 代码
var jsonObj = {};
//添加属性 key1 = val1
jsonObj.key1 = 'val1';
console.log(jsonObj);
//添加属性 key2 = val2
jsonObj['key2'] = 'val2';
console.log(jsonObj);
//添加属性 key1
delete jsonObj['key1'];
console.log(jsonObj);
控制台输出
{key1: "val1"}
{key1: "val1", key2: "val2"}
{key2: "val2"}
ConstXiong 备案号:苏ICP备16009629号-3