티스토리 뷰

const nicoInfo = [ "Nicolas", "55", "true", "seoul" ]; 배열

 

const nicoInfo = {  "Nicolas", "55", "true", "seoul"  } 객체라서 이렇게 쓸 수 없다! 대신,

const incoInfo - {

    name : "Nico",

    age : 33,

    gender : "Male",

    favMovies : ["Along the gods", "LOTR", "OldBoy"],  //문자를 적을때는 ""따옴표를 꼭 써라!

    inHandsome : true,

    favFood : [

        {

            name : "kimchi", //콤마를 절대 잊지 말라!

            fatty : false

         },

        {

            name : "cheese burger",

            fatty : true

         }

    ]

}

console.log(nicoInfo.gender); 이라고 하면 Male만 출력된다.

nikoInfo.gender = "Female"

console.log(nicoInfo.gender); = Female로 데이터가 업데이트 된다!

 

favFood안의 김치와 치즈버거는 배열속의 객체로 담겨있다.

'노마드코더 > 자바스크립트' 카테고리의 다른 글

#2-2 JS DOM Functions  (0) 2021.08.29
#2.1.1 More Function Fun  (0) 2021.08.29
#1-9 Organizing Data with Arrays  (0) 2021.08.27
#1-8 Data Types on JS  (1) 2021.08.21
#1-7 let, const, var  (0) 2021.08.21
댓글
© 2018 webstoryboy