zhyextends

1.1.2 • Public • Published

This is a perfect ES5 class extend module.


followings are a sample of how to use,
it will output these:

this data is from father
this msg is from father
__________________________
const {_extends}=require("./zhyextend.js");


var subcls=function(){
    this._super.constructor.apply(this,arguments);//super()
}

subcls.prototype.foo=function(){
    this._super.foo.apply(this,arguments); //super()

    console.log(this.datacopy);
    console.log(this.bar());
}
var cls=function(){
    this.data="this data is from father";
}
cls.prototype.foo=function(){
    this.datacopy=this.data;
}
cls.prototype.bar=function(){
    return "this msg is from father";
}

_extends(subcls,cls);

new subcls("1").foo();

Readme

Keywords

Package Sidebar

Install

npm i zhyextends

Weekly Downloads

1

Version

1.1.2

License

ISC

Unpacked Size

2.29 kB

Total Files

3

Last publish

Collaborators

  • zhyjs