JSON.parse() - 是把后端传过来的数据结构转换成对象(也称反序列化)
JSON.stringify() - 是把后端传过来的数据结构转换为字符串 (也称为序列化)
JSON.parse(JSON.stringify()) 是深拷贝
用法如下:
let arr = [1,2,3];
let res= JSON.parse(JSON.stringify(arr));
console.log(res);
用法如下:
let arr = [1,2,3];
let res= JSON.parse(JSON.stringify(arr));
console.log(res);