Created
June 2, 2011 20:57
-
-
Save mde/1005311 to your computer and use it in GitHub Desktop.
JS inheritance stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyThing = function () { | |
this.a = function () { | |
}; | |
this.b = []; | |
this.c = 'foo'; | |
}; | |
MyThing.prototype = new (function () { | |
var MY_SETTING = 2112; | |
var _myPrivateFunc = function () { | |
}; | |
this.qux = []; | |
this.foo = function () { | |
_myPrivateFunction.apply(this); | |
(function () { | |
}).apply(this, arguments); | |
}; | |
this.bar = function () {}; | |
})(); | |
MyMixin = new (function () { | |
this.zoobie = 2; | |
this.frang = false; | |
})(); | |
var foo = new MyThing() | |
, bar = new MyThing(); | |
for (var p in MyMixin) { | |
foo[p] = MyMixin[p]; | |
} | |
foo.qux.push(1); | |
bar.qux => ? | |
foo.qux = 'howdy'; | |
bar.qux => ? | |
delete foo.qux; | |
foo.qux => ? | |
bar.qux => ? | |
foo.foo(); | |
function foo () {} | |
var foo = function () {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment