26.
What will be the output of the following code?
const fruits = ["apple", "banana", "cherry"];
const removedFruit = fruits.pop();
console.log(removedFruit);
undefined
cherry
banana
apple
Correct: B
The pop() method removes the last element from an array and returns that element. In this code, the pop() method is called on the fruits array, which removes the last element cherry. The removed element is stored in the variable removedFruit. Therefore, when we print removedFruit using console.log(), it will output cherry.