setter
-
[JS] Getter와 SetterAlgorithm & Data Structure 2022. 1. 25. 22:34
자바스크립트는 객체 기반의 프로그래밍 언어이다. 객체는 0개 이상의 프로퍼티(property)로 구성된 집합이며, 프로퍼티는 key와 value로 구성된다. let person = { name: 'Dahee', // name~dahee까지 프로퍼티, name은 프로퍼티 키, dahee는 프로퍼티 밸류 }; 프로퍼티 value 가 함수일 경우에 메서드라 부른다. 개념 이해하는데 한참 걸린 getter와 setter... const person = { firstName: 'Dahee', lastName: 'Jo', get fullName() { return `${person.firstName} ${person.lastName}` }, set fullName(value) { const parts = value..