/* Array */
const arr = [1, 2, 3];
console.log(...arr); // Output: 1 2 3

/* String */
const str = "Hello World";
console.log(...str); // Output: "H e l l o   W o r l d"

/* DOM Collection */
const items = document.querySelectorAll(".item"); // Returns a NodeList
const itemsArray = [...items]; // Convert to an array using the Spread Syntax

// Now we can use array methods
itemsArray.forEach(item => {
    console.log(item.textContent);
});
const arr1 = [1, 2];
const arr2 = [3, 4];
const mergedArr = [...arr1, ...arr2];  // Merging arrays

console.log(mergedArr);  // [1, 2, 3, 4]
const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];

// Merging two arrays
const mergedArray = [...arr1, ...arr2];
console.log(mergedArray); // Output: [1, 2, 3, 4, 5, 6]

// Expanding the array by adding new elements
const extendedArray = [...arr1, 4, 5];
console.log(extendedArray); // Output: [1, 2, 3, 4, 5]
function sum(a, b, c) {
    return (a + b + c);
}
  
const numbers = [1, 2, 3];
  
const result = sum(...numbers); // Equivalent to sum(1, 2, 3)
console.log(result); // Output: 6
// Select all elements with the .item class in the HTML document
const items = document.querySelectorAll(".item");  // Returns a NodeList

// Convert the NodeList to an array using the Spread Syntax
const itemsArray = [...items];  

// Now that itemsArray is an array, you can use array methods
itemsArray.forEach(item => {
    console.log(item.textContent);  // Output text content of each .item element
});

// Merging with another array
const newItems = ["New Item 1", "New Item 2"];
const allItems = [...itemsArray, ...newItems];  // Merging the NodeList with the new array

console.log(allItems);  // NodeList + new array
const items = ...[1, 2, 3, 4]; // Uncaught SyntaxError
const obj = {
    a: 1,
    b: 2,
    c: 3
}

console.log(...obj); // Uncaught TypeError
const obj1 = {
    x: 1,
    y: 2
}

const obj2 = {
    z: 3
};

// 객체 병합
const mergedObj = {...obj1, ...obj2};
console.log(mergedObj);  // { x: 1, y: 2, z: 3 }