Skip to content

Instantly share code, notes, and snippets.

@shrynx
Created October 20, 2016 02:07
Show Gist options
  • Save shrynx/dd509f97580d564ea9a6ec7cb303ef98 to your computer and use it in GitHub Desktop.
Save shrynx/dd509f97580d564ea9a6ec7cb303ef98 to your computer and use it in GitHub Desktop.
// 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