const arr = [1, 2, 3];

// Removes the last element from the array
arr.pop();
console.log(arr); // Output: [1, 2]
arr.pop()
// Initialize the array
const arr = [1, 2, 3];

// Remove the last element from the array
const removedItem = arr.pop();
console.log(arr); // Output: [1, 2]
console.log("Returned value -", removedItem); // Output: 3

// Empty array
const emptyArray = [];
const emptyArrayRemovedItem = emptyArray.pop(); // Array is empty, no element to remove

console.log(emptyArrayRemovedItem); // Output: undefined
const fruits = ["apple", "banana", "cherry"];
const removedFruit = fruits.pop();

console.log(removedFruit); // Output: "cherry"
const fruits = ["apple", "banana", "cherry"];
fruits.pop();

console.log(fruits.length); // Output: 2
// Original array
const fruits = ["apple", "banana", "cherry"];

// Create an empty array for reversed elements
const reversedFruits = [];

// Use a loop to pop elements from the original array and push them into the new array
while (fruits.length > 0) {
    reversedFruits.push(fruits.pop());
}

// Output the reversed array
console.log(reversedFruits); // Output: ["cherry", "banana", "apple"]
const fruits = ["apple", "banana", "cherry"];

// Reverse the array
const reversedFruits = fruits.reverse();

// Output the reversed array
console.log(reversedFruits); // Output: ["cherry", "banana", "apple"]
const fruits = ["apple", "banana", "cherry"];

// Remove the last element using delete
delete fruits[fruits.length - 1];

// Output the array
console.log(fruits); // Output: ["apple", "banana", <empty>]
console.log(fruits[2]); // Output: undefined