Created
November 9, 2016 01:32
-
-
Save SyntaxStacks/edcc2000880091803afe77995d91b963 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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