1

I'm having the weirdest output where the debugger says the Node has 2 children when it has 3. Even the in the image I post here I see some incongruences, where it says the length of the object is 3 but for some reason, it prints that the length is 2.

enter image description here

Has anyone encountered this behaviour ?

Thanks for your help

Greggz
  • 1,873
  • 1
  • 12
  • 31
  • Cause `NodeList(2)` is logged, and the rest gets composed by the console when you click on it, thats "live", so the list changed inbetween. – Jonas Wilms May 07 '18 at 14:33
  • 1
    See the light blue box that has `i` in it on the right of `NodeList (2)`? [**Hover it**](https://i.stack.imgur.com/f6WTT.jpg). – ibrahim mahrir May 07 '18 at 14:33
  • [**Simillar problem**](https://stackoverflow.com/q/42260524/6647153) – ibrahim mahrir May 07 '18 at 14:35
  • @JonasW. Thanks ! – Greggz May 07 '18 at 14:36
  • @ibrahimmahrir Thank you – Greggz May 07 '18 at 14:37
  • You're calling this a "bug". In what way is this console behavior impacting your application code such that it causes a bug? –  May 07 '18 at 14:37
  • @CrazyTrain As I learned now, it's not a bug. In the beggining I didn't know that. Already edited the question – Greggz May 07 '18 at 14:39
  • Oh, I see. You thought the console had a bug. Yeah, consoles often reevaluate reference types, but generally not primitives or certain labels. Ultimately, it's up to them how their output behaves; there's no standard that describes a required behavior. –  May 07 '18 at 14:42
  • @CrazyTrain thanks good to know :) – Greggz May 07 '18 at 14:48

1 Answers1

2

Here's what is likely happening:

When you log the NodeList to the console it has 2 elements, but in the moment you expand the preview, it has 3 elements. The same effect can be observed, when you add an item to an array after a certain timeout:

console.log() changes the view live, so whenever the item changes you can see it when expanding it

Luca Kiebel
  • 9,790
  • 7
  • 29
  • 44