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"];

// 배열을 역순으로 정렬
$reversedFruits = fruits.reverse();

// 역순으로 정렬된 배열 출력
console.log($reversedFruits);

// 역순으로 정렬된 배열 출력
console.log(reversedFruits); // 출력: ["cherry", "banana", "apple"]
const fruits = ["apple", "banana", "cherry"];

// 배열의 마지막 요소를 제거
delete fruits[fruits.length - 1];

// 배열 출력
console.log(fruits); // 출력: ["cherry", "banana", <비어 있음>]
console.log(fruits[3]); // 출력: undefined