bhylu.com

Advertisements

Function Expressions

A function expression creates a function as a value. Store it, pass it, or return it like other values.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const double = function (value) {
  return value * 2;
};
console.log(double(4));

What happens

The stored function produces 8.