I'm launching a course about Next.js + React.jsLearn more

Node.js: Log over 100 Array elements

2018-04-12 · 1 min read

Using console.log on an array with over 100 elements results in the following output

// file.js
const arr = Array(500).fill('item');
node file.js

[ 'item',
  ... 400 more items ]

Only first 100 are displayed with a message that there are more elements.

Use util.inspect with maxArrayLength set to null to display more than 100 items from an array:

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

By default, in Node.js maxArrayLength is set to 100.

My Tech Newsletter

Get emails from me about programming & web development. I usually send it once a month