let codeit = {
name: '코드잇',
bornYear : 2017,
isVeryNice : true,
worstCourse : null,
bestCourse: {
title : '자바스크립트 프로그래밍 기초',
language : 'Javascript'
}
};
console.log(codeit.bornYear);
✖ 따옴표를 생략할 수 없는 프로퍼티 네임으로는 접근할 수 없다.
console.log(codeit.born year);
console.log(codeit.['born'+'Year']);
변수에 담긴 값도 활용할 수 있다.
let propertyName = 'name';
console.log(codeit.[propertyName]);
console.log(codeit.bestCourse.title);
console.log(codeit.bestCourse['title']);
// 프로퍼티 네임에 따라서 적절하게 활용하면 된다.
// 존재하지 않는 프로퍼티 네임에 접근하려고 하면 undefined 가 출력된다.