Skip to content

Instantly share code, notes, and snippets.

@niklasfi
Created February 7, 2011 21:35
Show Gist options
  • Save niklasfi/815268 to your computer and use it in GitHub Desktop.
Save niklasfi/815268 to your computer and use it in GitHub Desktop.
main.js
var foo = exports;
//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
foo = function(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?
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