프로토타입
-
[Javascript] - 프로토타입(prototype)Programming/Javascript 2019. 4. 8. 16:04
- Prototype(프로토타입) - Prototype(프로토타입)의 정의 - 객체지향언어의 특징인 Class라는 개념을 대체하는 Javascript의 문법 - Javascript에는 Class라는 개념이 없었지만 최근 ES6문법에 Class가 추가되었다 - 다른 객체지향언어(ex.Java, Python)의 상속이라는 개념을 Javascript에서는 Prototype(프로토타입)으로 구현할 수 있다 - Javascript가 프로토타입 기반 언어라고 불리는 이유는 Prototype문법이 있기 때문이다 Prototype(프로토타입)의 이해를 위한 예제 1 2 3 4 5 6 7 8 9 10 11 function Person() {}; Person.prototype.eyes = 2; Person.prototyp..