const arr = [1, 2, 3];

// 配列の最後の要素を削除します。
arr.pop();
console.log(arr); // 出力:[1, 2]
arr.pop()
const arr = [1, 2, 3];

// 配列の最後の要素を削除します。
const removedItem = arr.pop();
console.log(arr); // 出力:[1, 2]
console.log(removedItem); // 出力:3

// 配列が空の場合
const emptyArray = [];
const emptyArrayRemovedItem = emptyArray.pop(); // 削除する要素がなく、配列が空である

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

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

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

// 逆順の要素を格納するための空の配列を作成
const reversedFruits = [];

// ループを使用して末尾から要素を順に取り出し、逆順に再配置
while (fruits.length > 0) {
    reversedFruits.push(fruits.pop());
}

// 逆順になった配列を出力
console.log(reversedFruits); // 出力:["cherry", "banana", "apple"]
const fruits = ["apple", "banana", "cherry"];

// 配列を逆順にする
const reversedFruits = fruits.reverse();

// 逆順になった配列を出力
console.log(reversedFruits); // 出力:["cherry", "banana", "apple"]
const fruits = ["apple", "banana", "cherry"];

// 配列の最後の要素を削除
delete fruits[fruits.length - 1];

// 配列を出力
console.log(fruits); // 出力:["apple", "banana", <空>]
console.log(fruits[3]); // 出力:undefined