Inheritance Pattern - Javascript
Object.create()를 이용한 pseudoclassical inheritance function Shape() { this.x = 0; this.y = 0; } //superclass method Shape.prototype.move = function () { this.x += x; this.y += y; console.log('this shape is moved!'); } function Rectangle() { Shpae.call(this); } Rectangle.prototype = Object.create(Shape.prototype); Rectangle.prototype.constructor = Rectangle; Rectangle.prototype.move = function () {..
Programming/Concept
2019. 6. 4. 14:38