转储整个数组:console.log和console.dir输出"... NUM个更多项目]" [英] Dumping whole array: console.log and console.dir output "... NUM more items]"
本文介绍了转储整个数组:console.log和console.dir输出"... NUM个更多项目]"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图记录一个长数组,以便可以在终端中快速复制它.但是,如果我尝试记录该数组,则它看起来像:
I am trying to log a long array so I can copy it quickly in my terminal. However, if I try and log the array it looks like:
['item',
'item',
>>more items<<<
... 399 more items ]
如何记录整个阵列,以便可以真正快速地复制它?
How can I log the entire array so I can copy it really quickly?
推荐答案
设置maxArrayLength
有几种方法都需要设置maxArrayLength
,否则默认为100.
Setting maxArrayLength
There are a few methods all of which require setting maxArrayLength
which otherwise defaults to 100.
-
提供替代作为
console.dir
console.dir(myArry, {'maxArrayLength': null});
设置 util.inspect.defaultOptions.maxArrayLength = null;
,这将影响对console.log
的所有调用和util.format
Set util.inspect.defaultOptions.maxArrayLength = null;
which will impact all calls to console.log
and util.format
使用选项自己致电util.inspect
.
const util = require('util')
console.log(util.inspect(array, { maxArrayLength: null }))
这篇关于转储整个数组:console.log和console.dir输出"... NUM个更多项目]"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文