메모리에 남아있는 원형 object. 인스턴스에 프로퍼티를 정의하면 날라가지만 프로토타입에 프로퍼티를 저장하면 얘를 상속한 다른 object들이 다 갖고있게 됨

function Bike(gears, startGear) {
this.gears = gears;
this.currentGear = startGear;
}
Bike.prototype.changeGear = function(direction, changeBy) {
if (direction === 'up') {
this.currentGear += changeBy;
} else {
this.currentGear -= changeBy;
}
}
This way every object created from Bike inherits the changeGear function.

'개발' 카테고리의 다른 글
| 네트워크 - DHCP (0) | 2024.12.06 |
|---|---|
| IP주소, 서브넷 마스크 (1) | 2024.12.06 |
| Java - .java와 .class 파일, JVM (0) | 2024.12.06 |
| 코틀린 - 스코프 함수 let (0) | 2024.12.06 |
| Kotlin - 코루틴 (0) | 2024.12.06 |