我如何打印JavaScript对象/变量?
这个问题在这里已经有了答案:
将上面的示例更改为:
var user = {
first: 'Jack',
last: 'Green',
age: 54
};
// plain console log
console.log(JSON.stringify(user, undefined, 2));
// or with interpolation:
console.log(`User: ${JSON.stringify(user, undefined, 2)}`);
现在我们可以看到漂亮的输出:
{
"first": "Jack",
"last": "Green",
"age": 54
}
User: {
"first": "Jack",
"last": "Green",
"age": 54
}
链接地址: http://www.djcxy.com/p/8451.html