Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Function Expressions

A JavaScript function can also be defined using a function expression.

A function expression can be assigned to a variable.

Example

const x = function (a, b) {return a * b};

Once a function expression is stored in a variable, the variable can be used to invoke the function.

Example

const x = function (a, b) {return a * b};
let z = x(43);

The function above is an anonymous function, meaning it has no name.

Functions stored in variables do not require names and are always invoked using the variable name.

The function above ends with a semicolon because it is part of an executable statement.