المعرفة:: JavaScript
الحالة::مؤرشفة
المراجع:: The Complete JavaScript Course 2022 From Zero to Expert
- Closures are not a feature that we explicitly use, it happens automatically in certain situations, we just need to recognize those situations.
- Closure makes a function remember all the variables that existed when the function was created.
- Any function always has access to the variable environment of the execution context in which the function was created.
- Even though when the execution context has actually been destroyed, the variable environment somehow keeps living somewhere in the engine.
- A closure is the closed-over variable environment of the execution context in which a function was created, even after that execution context is gone.