Skip to content

JavaScript Foundations

FullstackCodingGuy edited this page Feb 10, 2025 · 5 revisions
Variables

image image image image

Reference

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

image image

Real World Scenario

image

Clone this wiki locally