Last active
August 29, 2015 13:57
-
-
Save user24/9736172 to your computer and use it in GitHub Desktop.
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
| // A way to use module pattern along with new keyword | |
| function Foo() { | |
| this.baz = 4; | |
| function bar() { | |
| return this.baz; | |
| } | |
| return { | |
| "bar":bar.bind(this) | |
| }; | |
| } | |
| var f = new Foo(); | |
| f.bar(); // 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jamesallardice just pointed out that this won't return an instance, so f instanceof Foo is false >:(
https://twitter.com/james_allardice/status/448013229143629824