Last active
January 31, 2018 02:43
-
-
Save wmantly/1fad88007dee6af8f287c6f7fa9c7b98 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
| file1.js ====================== | |
| console.log('file1 evaluated'); | |
| var up = 0 | |
| module.exports = { | |
| up: function(){ | |
| return ++up; | |
| }, | |
| value: function(){ | |
| return up; | |
| } | |
| }; | |
| file2.js ===================== | |
| const file1 = require('./file1'); | |
| console.log( 'file2.js', file1.up()) | |
| console.log( 'file2.js', file1.value()) | |
| app.js ======================= | |
| const file1 = require('./file1'); | |
| console.log( 'app.js', file1.up()) | |
| console.log( 'app.js', file1.value()) | |
| require('./file2') | |
| console.log( 'app.js', file1.value()) | |
| OUTPUT ====================== | |
| file1 evaluated | |
| app.js 1 | |
| app.js 1 | |
| file2.js 2 | |
| file2.js 2 | |
| app.js 2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment