-
-
Save isaacs/815301 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
module.exports = Foo; | |
//now i would like to have a constructor function for the foo "class" (i know in JS that does not exist) | |
//with normal js this would be | |
function Foo(arg1,arg2){ | |
this.something = arg1; | |
this.somethingOther = arg2; | |
} | |
//but this would override exports, which defeats the purpose of putting this "class" in a different file | |
//would also like to do | |
Foo.prototype.fnc1 = function(args){ | |
//do stuff | |
} | |
//i learned that declaring "static" functions this way is a good practice in JS. Is that also possible with require? |
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 Foo = require('./foo.js'); | |
var foo1 = new Foo("x","y"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment