Created
April 18, 2011 04:48
-
-
Save Nutrox/924831 to your computer and use it in GitHub Desktop.
This file contains 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 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