Each function has the same variable I in its scope chain, and when we execute the subfunctions in the array, the loop inside Foo has ended, and i = 10 , so each function call prints 10. ES6 makes it easier to fix such a problem by introducing let declaration variables that give JavaScript a block-level scope. Currying is a

3m read timeFrom enlear.academy
Post cover image
Table of contents
1. Implement block-level scope2. Save internal state3. Function Currying4. Modular mode

Sort: