Which of the following methods is used to remove the last element from an array in JavaScript?
a)
pop()
b)
shift()
c)
splice()
d)
remove()
Answer:
a)
pop()
Explanation:
The pop()
method is used to remove the last element from an array in JavaScript. It modifies the original array and returns the removed element.
Example:
let fruits = ["Apple", "Banana", "Cherry"];
let lastFruit = fruits.pop();
console.log(fruits); // Output: ["Apple", "Banana"]