Created
January 29, 2013 22:43
-
-
Save jakobo/4668680 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
8 -rw-r--r-- 1 jheuser 502 126 Jan 29 14:41 main.js | |
8 -rw-r--r-- 1 jheuser 502 212 Jan 29 14:41 testa.js | |
8 lrwxr-xr-x 1 jheuser 502 8 Jan 29 14:37 testb.js -> testa.js |
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 a = new (require('./testa'))('a'); | |
var b = new (require('./testb'))('b'); | |
console.log(a.varIs()); | |
console.log(b.varIs()); |
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 privateVariable = 1; | |
var myClass = function(name) { | |
this.name = name; | |
privateVariable++; | |
}; | |
myClass.prototype.varIs = function() { | |
return this.name + ': ' + privateVariable; | |
} | |
module.exports = myClass; |
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
$ node main.js | |
a: 3 | |
b: 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment