프로토타입상속1 JavaScript 기초(23)_객체(3) 1. 프로토타입의 상속 프로토타입의 상속에 대한 기초적인 예제를 아래와 같이 작성해보았다. // prototype 상속 function Person(){ } Person.prototype.hello = function(){ console.log('hello'); } function Korean(region){ this.region = region; this.where = function(){ console.log('where', this.region); }; } Korean.prototype = Person.prototype; const k = new Korean('seoul'); k.hello(); k.where(); [Running] n hello where seoul 비어있는 함수 Person의 프.. 2021. 10. 20. 이전 1 다음