Skip to content

Instantly share code, notes, and snippets.

@SyntaxStacks
Created November 9, 2016 01:32
Show Gist options
  • Save SyntaxStacks/edcc2000880091803afe77995d91b963 to your computer and use it in GitHub Desktop.
Save SyntaxStacks/edcc2000880091803afe77995d91b963 to your computer and use it in GitHub Desktop.
module.js
```
module.exports = function () {
return {
name: 'default',
set: function (name) {
this.name = name;
},
...
};
}
```
main.js
```
var mod = require('./module.js');
var foo = new mod();
var bar = new mod();
foo.set('jesse');
console.log(foo.name);
// 'jesse'
console.log(bar.name);
// 'default'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment