3

When I print an array, it shows up as a 100 element array of objects, but when I expand it, it doesn't expand. Instead, there is a blue info icon that says "Value below was evaluated just now", and the arrow changes direction. The problem is still there even if I clone my array when printing (which was an answer in another SO question).

I am actually using node.js with chrome debugger but I think the issue is the same. Here is my code

const axios = require('axios');

axios.get("https://--------")
  .then(function(response) {
    let data = response.data;
    console.log(data.slice(0, 100));
  });

axios just sends http requests.

I've read:
Is Chrome's JavaScript console lazy about evaluating arrays?
Weird behavior with objects & console.log

  • There are two explanations I think: a bug in Chrome/node.js or the code running at that time was accidentally different. Anyway, try JSON.parse(JSON.stringify(data)) or do a deepCopy. Or maybe the array is just 100 `undefined` values. – wOxxOm Jan 13 '21 at 07:17
  • yeah i tried JSON.parse(JSONstringify(...)) but it didn't work. Also if I just print it as a JSON string it is not undefined – Kevin the frog Jan 13 '21 at 16:56

1 Answers1

1

Your problem might be occurring because you are trying to expand the data structure after the debug session has ended.

Try add a debugger; after your console log to ensure you are expanding that array during your debug session.

Liam Pillay
  • 592
  • 1
  • 4
  • 19