ecmascript 6 - Javascript - Base class method not available in derived class when extending using lodAsh -


i have base class :

class base {     constructor() {          this.name = "base_class"         }      getbasename() {     return "base"     }  } 

and derived class

var _ = require('lodash'); class derived {     constructor() {         this.name = "derived"     }      getderivedname() {         return "derived"     } } _.extend(derived.prototype, base) 

i expecting have getbasename available in derived class. not case. should that? missing?

var derived = new derived(); console.log(derived.getbasename) -- undefined 

why using lodash extend es6 classes? can't use extends keyword?

class derived extends base {     constructor() {         super();         this.name = "derived"     }     getderivedname() {         return this.name;     } } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -