Skip to content

Instantly share code, notes, and snippets.

@Nutrox
Created April 18, 2011 04:48
Show Gist options
  • Save Nutrox/924831 to your computer and use it in GitHub Desktop.
Save Nutrox/924831 to your computer and use it in GitHub Desktop.
var Example = new function() {
var anotherWord = "banana";
return function ExampleConstructor( word ) {
this.word = word;
//
this.toString = toString;
this.getStatic = getStatic;
}
function toString() {
return this.word;
}
function getStatic() {
return anotherWord;
}
}
var exampleA = new Example("Foo");
var exampleB = new Example("Bob");
console.log( "Hello " + exampleA ); // Hello Foo
console.log( "Hello " + exampleB ); // Hello Bob
console.log( exampleA.getStatic() ); // banana
console.log( exampleB.getStatic() ); // banana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment