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: "Returned value - 3"

// Case 1: Empty array
const emptyArray_1 = [];
const emptyArray_1_removedItem = emptyArray_1.pop(); // Array is empty, no element to remove

console.log("Returned value -", emptyArray_1_removedItem); // Output: "Returned value -" undefined

// Case 2: Array with one element
const emptyArray_2 = [1];
const emptyArray_2_removedItem = emptyArray_2.pop();

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

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

console.log(fruits.length); // Outputs: 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); // Outputs: ["cherry", "banana", "apple"]
const fruits = ["apple", "banana", "cherry"];

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

// Output the reversed array
console.log(reversedFruits); // Outputs: ["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); // Outputs: ["apple", "banana", <empty>]
console.log(fruits[2]); // Outputs: undefined