Javascript consle prints Array 2?

var myArray = [["John", 23],["cat", 2]];


var removedFromMyArray = myArray.pop();



When I wrote the above script, it printed out on the console.log(myArray) = (Array 2)???

The removedfrommyarray printed out coorectly and cat and 2 where both shown but why wasnt John 23 printed out instead of Array 2`?

See below where I have added comments about what gets displayed to the console.

var myArray = [["John", 23],["cat", 2]];

console.log(myArray) // displays [ [ 'John', 23 ], [ 'cat', 2 ] ]

var removedFromMyArray = myArray.pop();

console.log(removedFromMyArray) // displays [ 'cat', 2 ]

console.log(myArray) // displays [ [ 'John', 23 ] ]

I am not understanding your question below. Which console.log statement (1st, 2nd, or 3rd) are you expecting something different than what gets displayed?

Thanks it just displaye (Array 2) and then if you check you find everything is in order. I just dont know why it didnt directly print out John and 23?

Which console.log statement are you talking about here?

Just printed array 2 but then there was an arrow and when I pressed it I found all my variables. Sorry for being confusing I am a TRUE BEGINER.


Seeing something like this? In the image above, DevTools simply representing Array that way (2) means two elements and the arrow is a convienient way to peek into the array and see what is going on inside. This way to represent arrays can be helpful, especially when array has a lot of elements, it may clutter your entire screen :slight_smile: Not sure if helps.

That is what I was asking exactly.

So that eans there was nothing wrong with my code and that is what is important.
Thank you all!