Created
August 22, 2019 13:35
-
-
Save cybaj/bfc365752c17d61b9df6a1627d074549 to your computer and use it in GitHub Desktop.
CommonJS JS file Scope
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
var module = require('./module.js') | |
val_main_global = 10000; | |
var val_main_var = 100000; | |
// console.log(val_mod_var); // ReferenceError | |
console.log("module.val_mod_var", module.val_mod_var); // undefined | |
console.log("val_mod_global", val_mod_global); // 10 | |
console.log("module.val_mod_global", module.val_mod_global); // undefined | |
// console.log(val_mod_let); // ReferenceError | |
console.log("module.val_mod_let", module.val_mod_let); // undefined | |
console.log("module.val_exp", module.val_exp); // 1000 |
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
var val_mod_var = 1; | |
val_mod_global = 10; | |
let val_mod_let= 100; | |
exports.val_exp = 1000; | |
// console.log('val_main_global', val_main_global) // ReferenceError | |
// console.log('val_main_var', val_main_var) // ReferenceError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment