Skip to content

Instantly share code, notes, and snippets.

@Gerjo
Created October 7, 2013 16:34
Show Gist options
  • Select an option

  • Save Gerjo/6870915 to your computer and use it in GitHub Desktop.

Select an option

Save Gerjo/6870915 to your computer and use it in GitHub Desktop.
Function with properties.
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