格式化输出:
let obj = { a: 'a1',b: 'b1' }; JSON.stringify(obj,null,2); //{ "a": "a1","b": "b1" }
巧用深拷贝:
let obj = { a: 'a1',b: 'b1' }; let copy = JSON.stringify(obj); let copyObj = JSON.parse(copy); copyObj.c = 0; //{a: "a1",b: "b1",c: 0} //{a: "a1",b: "b1"}
再有发现会陆续添加进来
原文链接:https://www.f2er.com/json/288830.html