newArr.pop

https://www.codecademy.com/courses/introduction-to-javascript/lessons/arrays/exercises/array-in-functions?action=resume_content_item

I put newArr.pop() into the function to remove the last element. My instinct here was to actually to put newArr = concept.pop();

It seems to do the same thing. Is there a reason to do it as the first way newArr.pop();
It also worked when I out in newArr = newArr.pop(); but I guess that is similar to the first way.

thanks!

1 Like

If you already have a reference to the array, surely there’s no need to do assignment?
Does pop change the original? If it did not change the original, would it have to copy the whole array?
What does array.pop return? I don’t think it’s the array itself, so when you say that behaves the same way that sounds like you’re not doing anything with the result (not measuring) and therefore see no difference

1 Like

Here is a link to the documentation to make the research go smoother. @ionatan is asking some good questions.