-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript Foundations
FullstackCodingGuy edited this page Feb 10, 2025
·
5 revisions
Closure Function
Situation
- We need a global variable but other functions should not be able to access/modify it - as any global variable are accessible inside functions.
- We need a local variable but that should persist previous state/value - as any local/private variables are reinitialized every time function is called.
Example
Real World Scenario