function literal

noun
UK /ˈfʌŋkʃən ˈlɪtərəl/
US /ˈfʌŋkʃən ˈlɪtərəl/

A function literal is a way to write a small set of instructions right where you need them.

Instead of naming a separate function, she passed a function literal directly to the button's click handler.


OTHER MEANINGS

2. In JavaScript, a function literal is an expression that creates a new function value, often assigned to a variable or passed as an argument.

const greet = function(name) { return 'Hello, ' + name; };

3. In some programming languages, a function literal can capture variables from its surrounding scope, forming a closure.

The function literal inside the loop captured the loop variable, so every callback saw the same final value.

4. A function literal differs from a function declaration because it is evaluated as part of an expression rather than hoisted by name.

Because it was a function literal, the code could not call it before the line where it was defined.