Skip to Content
자바스크립트 + 리액트 디자인 패턴
book

자바스크립트 + 리액트 디자인 패턴

by 애디 오스마니(Addy Osmani), 윤창식
August 2024
Beginner to intermediate
384 pages
7h 38m
Korean
Hanbit Media, Inc.
Content preview from 자바스크립트 + 리액트 디자인 패턴
59
Chapter 05_
최신 자바스크립트 문법과 기능
모든 최신 브라우저는 이러한 이점을 가진 모듈 가져오기
18
와 내보내기
19
를 지원하니 정상적
으로 사용할 수 있습니다.
5.9
생성자, 게터, 세터를 가진 클래스
ES2015
+에서는 모듈뿐만 아니라 생성자와 내부를 숨기는 기능을 가진 클래스
class
가 추가되
었습니다. 추가된 자바스크립트의 클래스는
class
키워드를 통해 사용할 수 있습니다. 다음
예제에서는 생성자와 두 개의 게터
Getter
와 세터
Setter
를 가진
Cake
클래스를 살펴보겠습니다.
class Cake{
// 생성자 안에서 변수를 정의합니다.
constructor( name, toppings, price, cakeSize ){
this.name = name;
this.cakeSize = cakeSize;
this.toppings = toppings;
this.price = price;
}
// ES2015 버전 이상에서는 모든 것을 함수로 만드는 것을 피하고자
// 새로운 식별자를 사용하려고 했습니다.
addTopping( topping ){
this.toppings.push( topping );
}
// 게터는 메서드 이름 앞에 넣어 사용합니다.
get allToppings(){
return this.toppings;
}
get ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AI를 위한 필수 수학

AI를 위한 필수 수학

할라 넬슨
클라우드 엔지니어를 위한 97가지 조언

클라우드 엔지니어를 위한 97가지 조언

Emily Freeman, Nathen Harvey, 정기훈(Jung Ki Hun)

Publisher Resources

ISBN: 9791169212571