Arrow Functions

  • This feature was introduced in ES6 version of Javascript to write more brief and short versions of functions.

  • This way we don't have to define a function with the keyword function anymore, we can just put our arguments inside the parentheses which is followed by a fat arrow => which is then followed by the function body.

Example:

const rectangleArea = (height, width) => {
    let area = height * width;
    return area;
}

console.log(rectangleArea(5, 4));

// Output: 20

Last updated