Manipulate Arrays With pop(), value ever assigned to parentheses?

Tell us what’s happening:
I understand what .pop() does, but is a value ever added inside the parentheses? or is it just understood that .pop() only removes the very last entry of an array?

Your code so far

// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

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

// Only change code below this line.
var removedFromMyArray = myArray.pop();

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Array.prototype.pop() doesn’t take values inside the parenthesis. Once you get more into javascript, you’ll be able to make your own Array.prototype.pop() method if you so desired.

edit: so yes, it just removes the last element of that array.

1 Like

It removes the last element array permanently from the original array and returns the value that has been removed.