Skip to content

Instantly share code, notes, and snippets.

View samuelfsd's full-sized avatar

Samuel Alves Medeiros samuelfsd

View GitHub Profile

Advanced JavaScript Concepts for Interview Preparation

Closures in JavaScript

A closure is a function paired with its surrounding lexical environment. It allows an inner function to retain access to the variables of an outer function even after the outer function has returned. Every time a function is created in JavaScript, a closure is formed at function creation time. This mechanism allows functions to “remember” and access their outer scope variables later on, enabling powerful patterns for state management and encapsulation.

Use Cases:

  • Data Privacy and State – maintaining a private counter or configuration that only your functions can access.
  • Function Factories and Currying – presetting arguments and returning new functions.
  • Caching and Memoization – storing previous results in a closure for performance.
@LukeberryPi
LukeberryPi / cv.tex
Created July 1, 2024 23:14
my cv NO INFO
\documentclass[a4paper,10pt]{article}
\usepackage[margin=0.5in,nofoot]{geometry}
\usepackage{fontawesome5}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{xcolor}
\hypersetup{
colorlinks=true,
linkcolor=blue,
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active August 10, 2025 14:02
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example