Skip to content
Create a constructor using a compact notation for inheritance and prototype extension.
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md
bower.json
declare.js
package.json

README.md

declare

Create a constructor using a compact notation for inheritance and prototype extension.

Installation

for Node

npm install oop-declare

for Bower

bower install declare

Usage

var Parent = declare(null,{
    init:function(params){
      declare.mixin(this,params);
      return this;
    },
    sayName:function(){
      console.log(this.name);
      return this;
    }
});

var Child = declare(Parent,{
    init:function(){
      Parent.prototype.init.apply(this,arguments);//strict mode
      //this.inherited(arguments);//non strict mode
      return this;
    },
    sayAge:function(){
      console.log(this.age);
      return this;
    }
});

var child = new Child({
  name:"Raoh",
  age:20
});

child.sayName().sayAge();
//Raoh
//20

License

MIT
Something went wrong with that request. Please try again.