If i double pop an array shouldn’t it be returned with all the elements except the last 2?

hello. i just discovered by mistake this result. if i double pop an array shouldn’t it be returned with all the elements except the last 2? instead i get the fourth element.

const chores = ['wash dishes', 'do laundry', 'take out trash', 'cook dinner', 'mop floor'];

chores.pop();
console.log(chores.pop())

returns “cook dinner”. why?

the .pop() methods returns the removed element

if you would log the array itself, you would get the array minus the removed elements.

2 Likes