Selfish how to call a parent initializer

I am using a selfish javascript library to simplify inheritance in javascript. For example, I have two objects

var Foo = Base.extend({ initialize: function(){ this.some_param = 1; } }), Bar = Base.extend({ initialize: function(){ this.another_param = 2; } }); 

How to call a Foo initializer from a string initializer?

+4
source share
1 answer
 var Foo = Base.extend({ initialize: function(){ this.some_param = 1; } }), Bar = Base.extend({ initialize: function(){ Foo.initialize.call(this); // <------- here this.another_param = 2; } }); 
+2
source

Source: https://habr.com/ru/post/1499352/


All Articles