Skip to content

Instantly share code, notes, and snippets.

@wmantly
Last active January 31, 2018 02:43
Show Gist options
  • Select an option

  • Save wmantly/1fad88007dee6af8f287c6f7fa9c7b98 to your computer and use it in GitHub Desktop.

Select an option

Save wmantly/1fad88007dee6af8f287c6f7fa9c7b98 to your computer and use it in GitHub Desktop.
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