Skip to content

Instantly share code, notes, and snippets.

@hasinur1997
Created November 22, 2024 05:11
Show Gist options
  • Save hasinur1997/a0e2bd16a28f7932a7daecf81c04d8ad to your computer and use it in GitHub Desktop.
Save hasinur1997/a0e2bd16a28f7932a7daecf81c04d8ad to your computer and use it in GitHub Desktop.

Javascript Notes

Closures: A closure is a function having access to the parent scope, even after the parent function has closed.

Example:

const add = (function () {
  let counter = 0;
  return function () {counter += 1; return counter}
})();

add();
add();
add();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment