Created
October 20, 2016 02:07
-
-
Save shrynx/dd509f97580d564ea9a6ec7cb303ef98 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
// module a.js | |
let a | |
function assignValueToA(val) { | |
a = val | |
calculateValueOfB(a) | |
} | |
// module b.js | |
let b | |
function calculateValueOfB(a) { | |
b = a + 100 | |
} | |
// main.js | |
// We assign a value 50 to variable a | |
assignValueToA(50) | |
// b now holds the value 150 | |
console.log(b) // 150 | |
// We change the value of a to 100 | |
assignValueToA(100) | |
// b now holds the value 200 | |
console.log(b) // 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment