typescript class

BackEnd_Ash.log·2021년 8월 11일
0

typescript

목록 보기
12/17

reference : 인프런 이재승님 강의

📌 Inheritance

if you inherit other class , you can use the variables and methods in the parent class

when creating a constructor in a child class, you must call super
if you not called super in a child class , an error occurs.

📌 method override

if the sayHello() method is called after the Programmer instance is created, the sayHello() method in the child class is called.

you only need to call it if you want

📌 access restrictor

  • public : as it is exposed externally, it is also exposed on the inheriting side.
  • protected : it is not exposed externally , but it is exposed on the inheriting side.
  • private : it is not exposed externally , it is also not exposed on the inheriting side.

by default, public is used

👉 private

if you use private access restrictor , occur an error when you object use

👉 protected

if you use protected occur an error when you create instance object and call protected variable

but you can use protected where it is inherited.

if you declare protected to constructor , you can't create instance object
so Person class can't make object

📌 readonly

readonly is literally read-only.

a readonly variable can't change it's value.

📌 getter , setter

📌 static

you can define a static method using the keyword static

a static member variable is a fixed value independent of each object.

📌 abstract class

be used to ing : ~ 하는데 익숙하다.
be used to : ~ 하곤했다.
be used : 사용되다 , 쓰이다.

an abstract class cannot be made into an object.

when an abstract class is used, the inheriting class must declare the variables and methods in the parent class.

profile
꾸준함이란 ... ?

0개의 댓글