Skip to content

Instantly share code, notes, and snippets.

@jbmilgrom
Created November 29, 2019 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbmilgrom/f7fd7fee9d3c6bb46d0020d807cd53c9 to your computer and use it in GitHub Desktop.
Save jbmilgrom/f7fd7fee9d3c6bb46d0020d807cd53c9 to your computer and use it in GitHub Desktop.
Highlight assignment of variable in closure construction
const makeBankAccount = balance => ({
withdraw: amount => balance = balance - amount, // <-- assign `balance` a new value
checkBalance: () => balance
});
const bankAccount = makeBankAccount(100);
bankAccount.withdraw(20);
bankAccount.checkBalance(); // 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment