Last active
May 6, 2016 02:36
-
-
Save RammusXu/80c736aba5a7ce874280646a4d49038b to your computer and use it in GitHub Desktop.
variable changed by other, but I just want to get a clone of it
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
var mo = require('./module')(); | |
console.log(mo); | |
var who = mo.A; | |
console.log(who); | |
who.name ='wal2er'; | |
console.log(who); | |
console.log(mo); |
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.exports = function() { | |
return { | |
A: { name: 'rammus', gender: 'man' }, | |
B: { name: 'J', gender: 'woman' } | |
}; | |
}; |
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.exports = { | |
A: { name: 'rammus', gender: 'man' }, | |
B: { name: 'J', gender: 'woman' } | |
}; |
Solution 1: use module-1.js
var mo = require('./module');
console.log(mo());
var who = mo().A;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result : module-1
result : module-2