-
Notifications
You must be signed in to change notification settings - Fork 6
在控制台完整地、格式化输出变量 #187
Copy link
Copy link
Closed
Labels
JSJavascriptJavascript
Description
需求描述
JavaScript 中在用 console.log 输出变量时,如果变量层级比较复杂,那么会输出 { e: 'e', f: [Object] } 这样的变量值。
如果要完整显示变量的每一层内容,并且将输出格式化(pretty-print),就需要进行特定的设置了。
解决过程
Google node.js beautify print nested object content,在 How can I pretty-print JSON using node.js? 中有一个优雅的解决方案:JSON.stringify(someObject, null, 2) 即可实现该需求。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
JSJavascriptJavascript