const constructorInherit = require('zhf.constructor-inherit');
function Super(opts = {}) {
this.name = 'hello world';
this.opts = opts;
}
Super.prototype.getAttribute = function () {
console.log(this.name, this.opts);
};
const superType = new Super({a: 1});
superType.getAttribute(); // 'hello world' {a: 1}
const Sub = constructorInherit(Super, {b: 2});
const subType = new Sub();
subType.getAttribute(); // 'hello world' {b: 2}
zhf.constructor-inherit
1.0.0 • Public • PublishedDependencies (2)
Dev Dependencies (14)
Package Sidebar
Install
npm i zhf.constructor-inherit
Weekly Downloads
1
Version
1.0.0
License
ISC
Unpacked Size
7.3 kB
Total Files
11