Created
March 13, 2020 20:35
-
-
Save all12jus/4458495e29be3a9bd67e4ac6c0ec79bf 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
const initApp = () => { | |
const print = () => { | |
console.log(num); | |
}; | |
var num = 0; | |
const increament = () => { | |
num++; | |
}; | |
return { | |
value: num, | |
print: print, | |
increament: increament, | |
}; | |
}; | |
var app = initApp(); | |
app.print(); // should print 0 | |
app.value += 1; // this doesn't actually change it. | |
// console.log(app.value); // this shows 1 | |
app.print(); // should print 1 | |
app.increament(); | |
app.print(); // this works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment