Arrow Functions in JavaScript
Overview of writing concise functions using arrow functions in JavaScript.
Background
Writing one-line functions, or generally small functions, is very common. The general approach to writing small functions is a long and tedious task. It also sometimes becomes messy and difficult to debug. The solution is arrow functions.
Introduction
Arrow function or an arrow function expression is the more concise syntax for writing regular function expressions. Also known as a fat arrow function, they utilize =>
token, which is shaped like a fat arrow. With their concise syntax, we avoid writing return
tokens, function
token, and curly brackets. Let’s look at the following syntax.
We make the representation of an arrow function concise with a one-line function. For a one-line function, we drop the curly brackets and the return statement. The expression or value is implicitly returned after the ...