I started with JS about 10 years ago and I fell in love with it (even though it can be weird 😅). I had step backs in my career that ended up being good. Currently I'm a passionate front-end developer.
As you can see 'grapes' now doesn't form part of the fruits variable but at the same time the pop() method returns the last item of the array. So clearly, if someone is going to use this method must be aware of this.
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
pop() method removes the last element from an array and returns that element. This method changes the length of the array.
Cool, i knew a little about the
pop()
method but now is more clear to me.Here is a small example of this
This would log:
As you can see
'grapes'
now doesn't form part of thefruits
variable but at the same time thepop()
method returns the last item of the array. So clearly, if someone is going to use this method must be aware of this.