【发布时间】:2022-01-17 01:23:08
【问题描述】:
【问题讨论】:
标签: javascript node.js
【问题讨论】:
标签: javascript node.js
这里说How can I get the full object in Node.js's console.log(), rather than '[Object]'?
您可以使用 json 直接转换您的元素(对象或数组)
console.log('my elem : %j', myObject);
或者如果你想要更多的显示选项,你可以使用 util.inspect
const util = require('util')
console.log(util.inspect(myObject, {showHidden: false, depth: null, colors: true}))
【讨论】:
你可以使用
console.dir(myArry, {'maxArrayLength': null});
控制台方法 log() 显示传递给它的任何对象的 toString 表示。控制台方法 dir() 显示指定 JavaScript 对象的属性的交互式列表
参考链接:Dumping whole array: console.log and console.dir output "... NUM more items]"
【讨论】:
通过JSON.stringify 运行它,因此您记录的是单个字符串而不是复杂的数据结构。
【讨论】: