我想删除单引号,把双引号中的JavaScript对象在数组中。
var arr=[{ email: '[email protected]', name: 'Abc' },
{ email: '[email protected]', name: 'Dr.Def' },
{ email: '[email protected]', name: 'Xyz' },
{ email: '[email protected]', name: 'Cad' }];
我想输出是这样的:
var arr=[{"email":"[email protected]","name":"Abc"},
{"email":"[email protected]","name":"Dr.Def"},
{"email":"[email protected]","name":"Xyz"},
{"email":"[email protected]","name":"Cad"}];
只是字符串化整个阵列?
var arr=[{ email: '[email protected]', name: 'Abc' },
{ email: '[email protected]', name: 'Dr.Def' },
{ email: '[email protected]', name: 'Xyz' },
{ email: '[email protected]', name: 'Cad' }];
console.log(JSON.stringify(arr))
如果你想var arr =
也只是在前面加上它console.log('var arr = ' + JSON.stringify(arr))
。