Return to site

Javascript reduce arrow function

broken image
broken image

The basic syntax is to write the keyword function, followed by a pair of parentheses. This means that inside an arrow function, this will always refer to the same object as it does outside the function.įor example, consider the following code: var obj = Writing arrow functions in JavaScript JavaScript arrow functions do not bind their own value of this, but instead inherit it from the enclosing scope. This is particularly useful for higher order functions, such as map, filter, and reduce.

broken image

They are less verbose, so they are easier to write and read.They are anonymous and are often used as inline functions.Īrrow functions have a few benefits over regular functions. Arrow functions are one of the most popular features of ES6, but what are they and how do you use them?Īn arrow function is a shorter way to write a function expression in JavaScript.

broken image