captured variable
nounUK /ˈkæptʃəd ˈveəriəbl/
US /ˈkæptʃərd ˈveriəbl/
A captured variable is a variable that a small piece of code keeps a copy of so it can use it later.
The inner function remembered the count because it was a captured variable.
RELATED WORDS
OTHER MEANINGS
2. In programming, a variable from an outer function that an inner function uses and keeps alive.
Each loop created a new captured variable, so the buttons showed different numbers.
3. A value that is saved by a function when the function is created, not when it runs.
The captured variable held the old value even after the outer code changed it.
4. A variable that a nested block borrows from the code around it.
The event handler used a captured variable to know which item was clicked.