Created
October 7, 2013 16:34
-
-
Save Gerjo/6870915 to your computer and use it in GitHub Desktop.
Function with properties.
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
| function MehBuilder() { | |
| // Ok... using an array b.c. strings are immutable. | |
| var foo = Meh.foo = ["derp"]; | |
| function Meh() { | |
| console.log(foo[0]); | |
| } | |
| return Meh; | |
| } | |
| var m = MehBuilder(); | |
| m.foo[0] = "dartvader"; | |
| var n = MehBuilder(); | |
| n.foo[0] = "homer"; | |
| m(); // dartvader | |
| n(); // homer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment