Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.22 KB

File metadata and controls

29 lines (22 loc) · 1.22 KB

Closure

iterators
maintain state in async
memoize an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.
partial application
scope the rules in any programming language for any given line of code, what data do i have available to me

{% hint style="info" %} COVE - closed over variable environment {% endhint %}

{% hint style="info" %} PLSRD - persistant, lexical or static, scoped, referenced, data

backpack = closure = [[scope]] = hidden data {% endhint %}

Closure gives our functions persistent memories and entirely new toolkit for writing professional code

helper functions everyday professional helper functions like once and memoize
iterators and generators which use lexical scoping and closure to achieve the most contemporary patterns for handling data in javascript
module pattern preserve state for the life of an application without polluting the gobal namespace
asynchronous javascript callbacks and promises rely on closure to persist state in an asynchronous environment