An arrow function expression has a shorter syntax than a function expression and does not bind its own:
These function expressions are best suited for non-method functions.
As an arrow function does not:
(param1 = defaultValue1, param2, …, paramN = defaultValueN) => { statements }
(param1 = defaultValue1, param2, …, paramN = defaultValueN) => expression // equivalent to { return expression; }
where:
The following syntax is also supported:
const myFunction = (param1: Type1, param2: Type2): ReturnType => {
// function body
}
var area = (r) => Math.PI * r ** 2;
var rayon = 3;
console.log(`The area of a circle with the rayon ${rayon} is ${area(rayon)}`);
var f = ([a, b] = [1, 2], {x: c} = {x: a + b}) => a + b + c;
where:
console.log(f()); // 6