nested function

noun
UK /ˈnɛstɪd ˈfʌŋkʃən/
US /ˈnɛstɪd ˈfʌŋkʃən/

A nested function is a function that is written inside another function.

In the code, the helper is a nested function because it lives inside the main function.


OTHER MEANINGS

2. A function defined within another function that can access the outer function's variables.

The nested function uses the counter variable from its parent function.

3. In mathematics, a function composed inside another function, like f(g(x)).

The nested function f(g(x)) applies g first and then f.

4. A programming technique where small helper functions are kept close to where they are used.

She used a nested function to keep the sorting logic tidy and local.