1、json.stringify和json.parse用处
JSON.stringify() 将对象a转化成字符串s;
JSON.parse() 将字符串s转化成对象a
this.emptyForm = JSON.parse(JSON.stringify(this.form))
let arr = [1,2,3];
JSON.stringify(arr);//'[1,2,3]'
typeof JSON.stringify(arr);//string
----------------------------------------------------
let string = '[1,2,3]';
console.log(JSON.parse(string))//[1,2,3]
console.log(typeof JSON.parse(string))//object
----------------------------------------------------
//判断数组是否包含某对象
let data = [
{name:'掘金'},
{name:'css学习'},
{name:'js学习'},
],
val = {name:'掘金'};
JSON.stringify(data).indexOf(JSON.stringify(val)) !== -1; // true