Created
November 29, 2019 18:16
-
-
Save jbmilgrom/f7fd7fee9d3c6bb46d0020d807cd53c9 to your computer and use it in GitHub Desktop.
Highlight assignment of variable in closure construction
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 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