Function expression
A function expression is an expression that creates a function value, which can be assigned, passed, or used within another expression.
Secrets of the JavaScript Ninja, Third Edition
A function expression is a JavaScript expression that creates a function and occurs as part of another expression or statement.
- How it is used
- Creates functions where values are needed, such as assignments, arguments, and return values.
- How deep it goes
- Defines expression placement through examples and contrasts it with declarations; defers detailed scope and identifier resolution.
- Examples
- Shows anonymous functions assigned to variables, passed as arguments, returned from functions, and called immediately.
- What you can do after
- Build it from scratch: place a function expression in an assignment, argument, return statement, or immediate call.
Read how Secrets of the JavaScript Ninja, Third Edition explains function expression →
Secrets of the JavaScript Ninja, Second Edition
A function defined as an expression rather than a declaration, producing a function value that can be assigned or passed around.
- How it is used
- Treats functions as first-class values that can be assigned, passed, or returned, while distinguishing expressions from declarations.
- How deep it goes
- Defines expression placement and naming, then flags invocation-availability differences without detailing them here.
- Examples
- Uses assignment to a variable, passing a function as an argument, returning a function, and immediate invocation.
- What you can do after
- Understand function expressions as values that can be assigned, passed as arguments, and returned.
Read how Secrets of the JavaScript Ninja, Second Edition explains function expression →
Also covered in
- React Quickly, Second Edition
- JavaScript in DepthIn early access (MEAP)
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- arrow functionAn arrow function is a JavaScript function expression written with arrow syntax that uses lexical binding for this and has no own arguments object.
- objectAn object is a distinct entity represented or manipulated within a computational system, typically as a value, data structure, resource, or instance of a type.
- scopeScope is the region of a program in which names are visible and can be resolved to their bindings according to the language’s rules.
Related concepts
- function declarationcontrasts with · A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
- immediately invoked function expressionincludes · An immediately invoked function expression is a JavaScript function expression that is defined and executed immediately within the same syntactic construct, often creating an isolated scope.
- arrow functioncontrasts with · An arrow function is a JavaScript function expression written with arrow syntax that uses lexical binding for this and has no own arguments object.
- functionkind of · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- handlerimplements · A handler is a software routine or component invoked to process an event, request, message, or other input.
Questions about function expression
What is function expression?
A function expression is an expression that creates a function value, which can be assigned, passed, or used within another expression.
Which Manning books explain function expression?
Secrets of the JavaScript Ninja, Third Edition and Secrets of the JavaScript Ninja, Second Edition.
What should I know before learning function expression?
Manning books that teach function expression usually introduce function, arrow function, object and scope first.
What is the difference between function expression and function declaration?
A function expression is an expression that creates a function value, which can be assigned, passed, or used within another expression. A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
What kinds of function expression are there?
Kinds of function expression include immediately invoked function expression and named function expression.
What is function expression a kind of?
Function expression is a kind of function. A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

