admin管理员组文章数量:1332345
I have a big array, it has many element,
I need to display it in console,
I use console.log()
but only a part of it was displayed.
How to display full content?
I have a big array, it has many element,
I need to display it in console,
I use console.log()
but only a part of it was displayed.
How to display full content?
Share Improve this question edited Dec 13, 2021 at 15:27 Álvaro González 147k45 gold badges279 silver badges376 bronze badges asked Dec 13, 2021 at 15:15 zwl1619zwl1619 4,23216 gold badges63 silver badges113 bronze badges4 Answers
Reset to default 3Run it through JSON.stringify
so you are logging a single string and not a plex data structure.
You can use
console.dir(myArry, {'maxArrayLength': null});
The console method log() displays the toString representation of any object passed to it. The Console method dir() displays an interactive list of the properties of the specified JavaScript object
Link for reference : Dumping whole array: console.log and console.dir output "... NUM more items]"
as say here How can I get the full object in Node.js's console.log(), rather than '[Object]'?
you can convert your element (object or array) directly in json by using
console.log('my elem : %j', myObject);
or if you want more display option, you can use util.inspect
const util = require('util')
console.log(util.inspect(myObject, {showHidden: false, depth: null, colors: true}))
For larger arrays, this works nicely:
myLargeArray.forEach( element => console.log( JSON.stringify( element ) ) );
本文标签:
版权声明:本文标题:javascript - the content is too long, How to display the complete content in console.log()? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742327722a2454059.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论