bhylu.com

Advertisements

Function Arrow

An arrow function is a compact function expression. A single expression can be returned without braces.

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 prices = [3, 5, 8];
const doubled = prices.map(price => price * 2);
console.log(doubled);

What happens

The new array is [6,10,16].