script에 javascript 객체로 담아서 선언할 수 있다.
const book = {
name: "자바스크립트 기초",
publisher: "oo출판사",
author: "피카츄",
price: 20000,
index: {
ch1: "소개",
ch2: "기초문법",
ch3: "연산자",
},
date: "2023년4월",
};
book이라는 객체에 name , publisher , author, price , index ( ch1 , ch2 , ch3 ) , date 값을 담아서 선언할 수 있다.
거기서 원하는 값을 뽑아낼 수 있다.
console.log("book type: ", typeof book);
console.log(book);
console.log(book.name);
console.log(book.publisher);
console.log(book.price);
console.log(book.index.ch3);
index 같은 경우에도 유용하게 쓸 수 있다.
'Java > Java icia 6일차' 카테고리의 다른 글
다차원 배열 (0) | 2023.02.28 |
---|---|
배열을 이용해 은행시스템 만들기 (0) | 2023.02.28 |
배열을 이용해 로그인 시스템만들기 (0) | 2023.02.28 |
배열_예제 추가 (0) | 2023.02.28 |