Skip to content

Instantly share code, notes, and snippets.

@jessecravens
Created March 29, 2012 17:33
Show Gist options
  • Save jessecravens/2240452 to your computer and use it in GitHub Desktop.
Save jessecravens/2240452 to your computer and use it in GitHub Desktop.
JavaScript Modules - commonJS
// defining a module
// making the hello method accessible
exports.hello = function() {
return 'Hello World'
};
// require the module elsewhere such as app.js - application entry point
var example = require('./example.js');
example.hello();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment