Closures
A closure is a function that retains access to variables from the scope in which it was defined, even after that outer scope has finished executing.
18 resources across 4 libraries
Glossary Terms(4)
Closures
A closure is a function that retains access to variables from the scope in which it was defined, even after that outer scope has finished executing.
Higher-Order Functions
A higher-order function is a function that takes one or more functions as arguments, returns a function as its result, or both.
Encapsulation
Encapsulation is an object-oriented programming principle that bundles data and the methods that operate on it within a single unit (a class), while restrictin…
Event Loop
The event loop is the mechanism that allows a single-threaded runtime, like JavaScript's, to handle asynchronous operations by continuously checking a queue of…
Study Notes(11)
Closures in LISP
How LISP closures bundle a function with its lexical environment to create private, persistent state, and common patterns and pitfalls that follow from it.
Anonymous Functions and Closures
Learn Julia's -> syntax for anonymous functions, do-block syntax, and how closures capture variables from their enclosing scope.
Delegates and Closures
Understand D's delegate type, how closures capture context, and how delegates power callbacks and higher-order functions.
Arrow Functions and Closures
Explore Dart's compact arrow (=>) function syntax and how closures capture enclosing variables to power callbacks and higher-order functions.
Closures in Lua
Understand how Lua closures capture upvalues by reference, how to use them for private state and per-iteration loop callbacks, and common closure-based pattern…
Closures in Groovy
How Groovy's first-class Closure type captures its defining scope, and how owner, delegate, and resolveStrategy power Groovy's DSL syntax.
Closures in Perl
Understand how Perl closures capture lexical variables to create private state, counters, and callback generators using anonymous subroutines.
Closures in JavaScript
Understand how closures let inner functions remember and access variables from their outer scope, and how loop variable capture can trip you up.
Closures in Go
Explore how Go closures capture and reference variables from their enclosing scope.
Closures in Rust
Understand Rust closures, their capture modes, and the Fn, FnMut, and FnOnce traits that govern how they use captured variables.
Closures in Swift
Understand closures as self-contained blocks of functionality that capture and store references to surrounding variables.
Cheat Sheets(1)
Interview Questions(2)
What Is a Closure in JavaScript?
A closure is a function bundled together with references to the variables from its enclosing lexical scope, so the function keeps access to those variables eve…
What Is Currying in JavaScript?
Currying is the technique of transforming a function that takes multiple arguments into a sequence of functions that each take a single argument, returning a n…