Last active
December 14, 2015 12:58
-
-
Save island205/5089778 to your computer and use it in GitHub Desktop.
This file contains 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
// File: global.js | |
var timestamp = new Date() | |
exports.global = { | |
timestamp: timestamp | |
} | |
console.log('timestemp from global.js is ' + timestamp) | |
// File: foo.js | |
var _global = require('./global').global | |
console.log('timestemp from foo.js is ' + _global.timestamp) | |
console.log('change timestamp to ' + (_global.timestamp = new Date())) | |
// File: bar.js | |
var _global = require('./global').global | |
require('./foo') | |
console.log('timestemp from bar.js is ' + _global.timestamp) | |
// git bash | |
// node bar.js | |
// timestemp from global.js is Tue Mar 05 2013 19:42:21 GMT+0800 (中国标准时间) | |
// timestemp from foo.js is Tue Mar 05 2013 19:42:21 GMT+0800 (中国标准时间) | |
// change timestamp to Tue Mar 05 2013 19:42:21 GMT+0800 (中国标准时间) | |
// timestemp from bar.js is Tue Mar 05 2013 19:42:21 GMT+0800 (中国标准时间) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment