Can we remove more values using .pop() operator?

mtf
Is .pop() operater only use to remove one value from the end?

Can we remove more values using .pop() operator?

Array.pop() is a method (not an operator) that can only remove one element at a time from the right side of the array.

a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
b = a.pop()
console.log(a)    //  [1, 2, 3, 4, 5, 6, 7, 8]
console.log(b)    //  9

We can remove more values using the Array.splice() method but there is no value returned since the method is in-place.

2 Likes

Thanks mtf your teaching is so understandable.

2 Likes