There are two ways of writing arrow functions: concise and fat. In this post we are focusing only on the concise way.
(param1, param2) => do something with param1 and param2
To implement a function to add two numbers in consise way, we can use arrow functions like this:
//consise arrow function for adding two numbers const add = (x, y) => x + y;
The arrow function example above allows us to get the same result with fewer lines of code and approximately half the typing.
//consise arrow function to get even numbers from an array const even = array.filter(v => v % 2 === 0);
Leave a Reply