반응형 Prototype1 (js) prototype 상속 연습 prototype 상속 기본형 연습 function Vehicle(name) { this.name = name this.isOn = false } Vehicle.prototype.start = function() { this.isOn = true console.log(this.name + ' is on') } Vehicle.prototype.turnOff = function() { this.isOn = false console.log(this.name + ' turned off') } Vehicle.prototype.drive = function() { if(this.isOn) { console.log(this.name + ' is moving') } else { console.log(this.name .. 2021. 8. 22. 이전 1 다음 반응형