+ 2
Why does it display "undefined"?
var man = [8, 6, 7]; man.pop(); console.log(man[2]); Explain, please 🙏
7 odpowiedzi
+ 4
Pop method used to eliminate the last element of the array and according to your process you want to put in console the element you have just eliminated so it will show undefined as you have already cleaned up that element adress in memory
Var man[8,6,7]
Man.pop =[8,6]
Console.log[2] =undefined
+ 6
Because you removed the last item in the array ( on index [2] ) with the pop() method. That's why it's empty/undefined now.
+ 6
Sorry..the other answers weren't there before I started writing. :)
+ 3
Hi, pop method deletes last element of your array and returns it. So your array doesn't have this element more.
+ 2
Remember also that the array started from zero index not one
+ 2
Thank you very much🙏 now I understand😅👌
+ 2
Anyway, thank you very much for not showing indifference) 🤗