본문 바로가기

상속2

13Jan2020 TIL 상위 개체의 메소드를 불러오는 방법 : 상위개체.prototype.method.call(this, arguments) FlyingHorse.prototype.goSomewhere = function(destination, milesToDestination) { if (milesToDestination < 10) { return Horse.prototype.goSomewhere.call(this, destination); } else { return this.name + " is flying to " + destination + "!"; } }; 굳이 따로 지정해줄 필요는 없었다. 아래의 예제 처럼 (내가 쓴것^^!) var FlyingHorse = function(name, color) { Horse.c.. 2020. 1. 13.
28Dec2019 TIL Today I learned : inheritance Pattern (Pseudo-classical / ES6 class) .bind //functional var makeDancer = (timeBetweenSteps) => { const dancer = {}; dancer.step = () => { setTimeout(dancer.step, timeBetweenSteps); }; } //pseudo-classical var Dancer = function (timeBetweenSteps) { this.timeBetweenSteps = timeBetweenSteps; }; Dancer.prototype.step = function () { setTimeout(this.step.bind(step, thi.. 2019. 12. 29.