1

I don't understand the output of this code :

var tab = [];
console.log(tab);
tab.push("Hello");

The console will display this :

[]
0: "Hello"
length: 1
__proto__: Array(0)

Why does it display "Hello" ?

Can someone explain to me ?

Thanks,

  • Have a read here as well https://stackoverflow.com/questions/23392111/console-log-async-or-sync – Devan Buggay Jan 25 '18 at 23:09
  • 1
    If you looked at what is actually displayed, you'll see a little `i` beside the expanded list which when hovered over explicitly states: *"Value below was evaluated just now."*. As the marked duplicate states in a couple places `JSON.stringify(tab)` is probably the most useful way to output it if you want it to stay consistent. – Nick is tired Jan 25 '18 at 23:16
  • Thank you Nick ! – Vincent Mesquita Jan 26 '18 at 10:19

0 Answers0