학습 목표
- 열과 객체의 특징을 구분하고, 배열과 객체의 특징에 따라 웹 애플리케이션 개발 시 어떻게 사용되는지 이해한다.
- 객체 속성(property)의 추가, 조회, 변경, 삭제를 자유자재로 할 수 있다.
- 객체 속성 조회법 두 가지, dot notation과 bracket notation의 차이를 이해한다.
- 배열과 객체, 반복문을 응용하여 능숙하게 대량의 정보를 다룰 수 있다.
let user = {
firstName: 'Steve',
lastName: 'lee',
email: 'steve@email.com',
city: 'Seoul'
키(key): 값(vlaue)
중괄호를 이용해서 객체를 만들고, 키-값 쌍은 쉼표로 구분
객체의 값을 사용하는 방법은 2가지
user.firstName; // 'Steve'
user.city; // 'Seoul'
user['firstName']; // 'Steve'
user['city']; // 'Seoul'
console.log(user.name); //'Steve'
console.log(user.city); // 'Seoul'
console.log(user['name']; // 'Steve'
console.log(user['city']; // 'Seoul'
user.job = 'Engineer';
user ['job'] = 'Engineer';
delete user.job;
delete user['job'];