January 11, 2022
A programming language is said to have First-class functions when functions in that language are treated like any other variable.
First-class function - MDN
Assign a function to a variable
Or store it in other data structures like objects and arrays.
Pass a function as an argument to another function
And then call it from the inside of this function
Return a function from another function
Note: A function that returns a function is called a Higher-Order Function.
First-class Function - MDN
Scope and Closures