객체 리터럴
-
10장 객체 리터럴 | 모던 자바스크립트 Deep Dive모던 자바스크립트 Deep Dive 2023. 11. 2. 19:36
객체란? 자바스크립트는 객체 기반의 프로그래밍 언어이며, 자바스크립트를 구성하는 거의 "모든 것"이 객체다. 원시 값을 제외한 나머지 값(함수, 배열, 정규 표현식 등)은 객체다. 원시 타입은 단 하나의 값만 나타내지만 객체 타입은 다양한 타입의 값(원시 값 또는 다른 객체)을 하나의 단위로 구성한 복잡한 자료구조다. 또한 원시 타입의 값, 즉 원시 값은 변경 불가능한 값(immutable value)이지만 객체 타입의 값, 즉 객체는 변경 가능한 값(mutable value)이다. var counter = { num: 0,// 프로퍼티 increase: function () { // 메서드 this.num++; } }; 객체는 0개이상의 프로퍼티로 구성된 집합이며, 프로퍼티는 키와 값으로 구성된다. 객..