Skip to content

Commit

Permalink
static scope
Browse files Browse the repository at this point in the history
  • Loading branch information
openhoat committed Mar 1, 2015
1 parent 6b18ae5 commit 6633160
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,22 @@ Subclazz = instanceFactory.createClass('Subclazz', {
}
}
});
Child = instanceFactory.createClass('Child', {
parent: Subclazz,
defaults: {c: 6},
methods: {
getA: function () {
return this.parent.getA.apply(this) * 2;
},
getC: function () {
return this.c;
},
getSum: function () {
return this.a + this.b + this.c;
Child = instanceFactory.createClass('Child', function () { // class desc can also be specified with a function
return {
parent: Subclazz,
defaults: {c: 6},
methods: {
getA: function () {
return this.parent.getA.apply(this) * 2;
},
getC: function () {
return this.c;
},
getSum: function () {
return this.a + this.b + this.c;
}
}
}
};
});
o = new Child();
console.log(o instanceof Child);
Expand Down

0 comments on commit 6633160

Please sign in to comment.