Class

차노·2023년 8월 2일
0

JS

목록 보기
7/96

Classes are a template for creating objects. They encapsulate data with code to work on that data. Classes in JS are built on prototypes but also have some syntax and semantics that are unique to classes.

Defining classes

classes are in fact "special functions", and just as you can define function expressions and function declarations, a class can be defined in two ways.

Like function expressions, class expressions may be anonymous, or have a name that's different from the variable that it's assigend to. However, unlike function declarations, class declarations have the same temporal dead zone restrictions as let or const and behave as if they are not hoisted.

A class element can be characterized by three aspects:

  • Kind: Getter, setter, method, or field
  • Location: Static or instance
  • Visibility: Public or private

0개의 댓글