Function within a function, but to make something remain in memory.

If a function references in the parent scope, it will be added to the heap instead of the call stack, making it longer lived. More memory, more computation.

This is a closure:

Untitled

Also used for function factories:

Untitled