CommonJS Pattern

3 Core Parts of the CommonJS pattern

1.Reference modules you want to use, with the require function

var dependency = require('/path/file');  

2.Declare the module

var Module = {  

3.Expose the module to others

module.exports = Module;  

Duncan Leung

Front End Developer at

Irvine, CA

Subscribe to Duncan Leung: Javascript and Front End Development

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!