Array methods shorthand

JavaScript’s array methods pass their values through to the functions given to them. If you would only forward those to another function, you can skip the arrow function and name that function directly.

const numbers = [4, 8, 15, 16, 23, 42]
const isEven = n => n % 2 === 0

numbers.filter(number => isEven(number))  // ⇒ [4, 8, 16, 42]
numbers.filter(isEven)                    // ⇒ [4, 8, 16, 42]

There is more to learn

Get free previews of my upcoming course materials and other bonus content to help you work smarter. I share tips straight to your inbox once a week. You can read previous mails in the newsletter archive.

Cannot show form because cookie consent was not given.