-
[JS] Chapter 5. 객체codeStates front-end/Java Script 2023. 1. 4. 10:22반응형
객채(Object)
객체의 값을 사용하는 방법
let user = { firstName : 'Steve' , lastName : ':Martin' , email : 'steve@gmail.com' , city : 'NY' }; user.firstName; // 1. Dot notation user.city; // 1. Dot notation user['firstName']; // 2. Bracket notation user['city']; // 2. Bracket notation /* [] 안 '', "", 백티 로 반드시 감싸줘야 한다*/
정리
let tweet = { writer : 'Steeve Martin' createdAt : '2022-02-03' content : 'so funny!' } tweet['content'] === tweet.content; // true tweet['category'] = '잡담'; tweet.isPiblic = true; tweet.tags = ['A','B']; delete tweet.createdAt; // 삭제 연산자 'content' in tweet; // in연산자로 키가 있는지 확인
반응형'codeStates front-end > Java Script' 카테고리의 다른 글
[JS] Chapter 7. 스코프 (0) 2023.01.05 [JS] Chapter 6. 원시 자료형과 참조 자료형의 특징과 종류 (0) 2023.01.04 [JS] Chapter 4. 배열 (0) 2023.01.04 [JS] Chapter 3. 함수 (0) 2023.01.04 [JS] Chapter 2. 조건문, 반복문 (0) 2023.01.04