Skip to content

Instantly share code, notes, and snippets.

@all12jus
Created March 13, 2020 20:35
Show Gist options
  • Save all12jus/4458495e29be3a9bd67e4ac6c0ec79bf to your computer and use it in GitHub Desktop.
Save all12jus/4458495e29be3a9bd67e4ac6c0ec79bf to your computer and use it in GitHub Desktop.
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