Add to the end with push(), remove from the end with pop():
let stack = [1, 2]
stack.push(3) // Add to end
console.log(stack) // [1, 2, 3]
let last = stack.pop() // Remove from end
console.log(last) // 3
console.log(stack) // [1, 2]
These operations are fast ( time and space). Use them when working with the end of arrays. push() returns the new length. pop() returns the removed element.