Object-Oriented Programming
1. 객체 지향이란
2. 클래스 모듈 패턴
메소드 호출
let counter1 = {
value: 0;
increase: function() {
this.value++ // 메소드 호출을 할 경우, this는 counter1을 가리킴
},
decrease: function() {
this.value--
},
getValue: function() {
return this.value
}
}
counter1.increase()
counter1.decrease()
counter1.increase()
counter1.decrease()
counter1.getValue() // 2클로저를 이용해 매번 새로운 객체 생성하기
3. 클래스와 인스턴스
클래스를 만드는 문법: class 키워드
클래스의 인스턴스 만들기
this: 인스턴스 객체
메소드 정의
정리
4. 객체 지향 프로그래밍
절차적 언어 > 객체 지향 언어
OOP의 네 가지 기본 개념
(1) Encapsulation(캡슐화)
(2) Inheritance(상속)
(3) Abstraction(추상화)
(4) Polymorphism(다형성)
5. 프로토타입
프로토타입과 클래스
프로토타입 체인
Last updated