转储整个数组:console.log 和 console.dir 输出“... NUM more items]"; [英] Dumping whole array: console.log and console.dir output "... NUM more items]"

查看:35
本文介绍了转储整个数组:console.log 和 console.dir 输出“... NUM more items]";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试记录一个长数组,以便我可以在终端中快速复制它.但是,如果我尝试记录数组,它看起来像:

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.

  1. 提供覆盖作为 console.dir

console.dir(myArry, {'maxArrayLength': null});

  • 设置util.inspect.defaultOptions.maxArrayLength = null; 这将影响对 console.logutil.format

    使用选项util.inspect>.

    Call util.inspect yourself with options.

    const util = require('util')
    console.log(util.inspect(array, { maxArrayLength: null }))
    

  • 这篇关于转储整个数组:console.log 和 console.dir 输出“... NUM more items]";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆