From 8605468737e3e1c30f371581797f36684bb18d1e Mon Sep 17 00:00:00 2001 From: Hyuntak Cha Date: Mon, 4 Mar 2019 16:12:47 +0900 Subject: [PATCH] Inheritance with regarding static method To inherit static method of the parent class, in es5, the child function's prototype link called `__proto__` should be assigned as parent function itself. For example, --- features.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/features.txt b/features.txt index 1f36866..624e7cd 100644 --- a/features.txt +++ b/features.txt @@ -682,12 +682,14 @@ More intuitive, OOP-style and boilerplate-free inheritance. 5| }; 5| |Rectangle.prototype = Object.create(Shape.prototype)|; 5| |Rectangle.prototype.constructor = Rectangle|; +5| |Rectangle.__proto__ = Shape|; 5| var Circle = function (id, x, y, radius) { 5| |Shape.call|(this, id, x, y); 5| this.radius = radius; 5| }; 5| |Circle.prototype = Object.create(Shape.prototype)|; 5| |Circle.prototype.constructor = Circle|; +5| |Circle.__proto__ = Shape|; Class Inheritance, From Expressions -----------------------------------