Arrow function expressions on JavaScript ES6

Arrow function is is a new expression to write functions instead of traditional function code.

We will show you different forms of arrow functions in this article.

General form of arrow function

let sumTwoNumbers = ( x, y ) => {
  return x + y;
}

One line shortcut

sumTwoNumbers = ( x, y ) => x + y;

You can remove body of the arrow function is case of having only one line, and you can remove return statement as well.

One parameter shortcut

let bob = a => a + 100;

You can remove parentheses of function parameter when having only one variable as a parameter.

1 thought on “Arrow function expressions on JavaScript ES6”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top