Preview:
When to Use
In situations where the this keyword isn't being used inside the body of a function, do what you think is best! For instance, it's quite convenient to use arrow functions in callbacks because of their short syntax:
Copy code
JAVASCRIPT
const numbers = [2, 3, 5];
const doubledNumbers = numbers.map(number => number * 2);

console.log(doubledNumbers); // 4, 6, 10 
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter