const fruits = ["apple", "orange", "banana"];
console.log(fruits.length); // 3

const emptyArr = [];
console.log(emptyArr.length); // 0
const greeting = "환영합니다. 반값습니다!";
console.log(greeting.length); // 13

const emptyStr = "";
console.log(emptyStr.length); // 0
function myFunction(a, b, c) {
  console.log(arguments.length);
}

myFunction(); // 0
myFunction(1); // 1
myFunction(1, 2); // 2
myFunction(1, 2, 3); // 3
const elements = document.querySelectorAll("p");
console.log(elements.length); // 요소의 개수
let str = "Hello, World!";
console.log(str.length); // 13

// length 속성을 수정하려고 시도
str.length = 5;

console.log(str.length); // 여전히 13
console.log(str);        // "Hello, World!" 그대로 유지됨
let arr = ["Apple", "Banana", "Orange", "Grape"];
console.log(arr.length); // 4

// 1. length를 현재보다 작게 수정 (배열 단축)
arr.length = 2; 
console.log(arr.length); // 2
console.log(arr);        // ["Apple", "Banana"] -> 나머지 요소는 영구적으로 삭제됨

// 2. length를 현재보다 크게 수정 (배열 확장)
arr.length = 5;
console.log(arr.length); // 5
console.log(arr);        // ["Apple", "Banana", empty × 3] -> 빈 공간(hole)이 생김

// 3. 다시 원래 데이터로 복구하려고 해도 삭제된 데이터는 돌아오지 않음
console.log(arr[2]);     // undefined