Object란?

각 value에 이름을 줄 수 있다.

Object를 선언하기 위해서는 {컬리 브라켓}을 써주면 된다.

const nicoInfo = {
            name:"Nico",
            age:33,
            gender:"Male",
            isHandsome:true,
        }

console.log(nicoInfo.gender)

//Male

 

선언 한 뒤 다시 선언하면 데이터가 변경되서 출력하는걸 확인할 수 있다.

const nicoInfo = {
            name:"Nico",
            age:33,
            gender:"Male",
            isHandsome:true,
        }

nicoInfo.gender = "Female"

console.log(nicoInfo.gender)

//Female

 

객체안에 배열을 넣을 수 있다. 또한, 배열안에 객체를 넣을 수 있다.

const nicoInfo = {
            name:"Nico",
            age:33,
            gender:"Male",
            isHandsome:true,
            favMovies: ["Along the gods", "LOTR", "Oldboy"],
            favFood: [
                {name: "Kimchi", fatty: false}, 
                {name: "Cheese burger", fatty: true}
            ]
        };

console.log(nicoInfo.favFood[0].name);
console.log(nicoInfo.favFood[1]);

//Kimchi
//{name: "Cheese burger", fatty: true}