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
Post a Comment