Skip to content

Instantly share code, notes, and snippets.

@jakobo
Created January 29, 2013 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakobo/4668680 to your computer and use it in GitHub Desktop.
Save jakobo/4668680 to your computer and use it in GitHub Desktop.
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
var a = new (require('./testa'))('a');
var b = new (require('./testb'))('b');
console.log(a.varIs());
console.log(b.varIs());
var privateVariable = 1;
var myClass = function(name) {
this.name = name;
privateVariable++;
};
myClass.prototype.varIs = function() {
return this.name + ': ' + privateVariable;
}
module.exports = myClass;
$ 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