Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 반복문
- java 백준 1차원 배열
- 카카오
- 명령어
- Java
- 연습문제
- 코테
- 백준 java
- Kotlin
- 고잉버스
- 월간코드챌린지
- 스프링 빈
- 코딩테스트
- 스프링 컨테이너
- 문자열
- GoingBus
- 리눅스마스터 1급 정리
- Linux
- 리눅스마스터1급
- 리눅스
- 자바
- 개발자 회고록
- 백준 javascript
- 리눅스마스터 3과목
- JavaScript
- toCharArray
- 프로그래머스
- 자바스크립트 코딩의 기술
- Memoir
- map
Archives
- Today
- Total
728x90
목록 javascript getter setter (1)
728x90
728x90
hoon DevLog

8장 클래스로 인터페이스를 간결하게 유지하라 tip40. get과 set으로 인터페이스를 단순하게 만들어라 이전 팁에서 사용한 코드를 활용하여, 클래스는 아래 코드처럼 속성에 접근하여 변경도 가능하다. class Coupon { constructor(price, expiration) { this.price = price; this.expiration = expiration || '2주'; } getPriceText() { return `$ ${this.price}`; } getExpirationMessage() { return `이 쿠폰은 ${this.expiration} 후에 만료됩니다.`; } } const coupon = new Coupon(5); coupon.price = '$10'; coupon..
IT/Javascript
2024. 2. 29. 09:23