BRAHMA TECHNOLAB

Reading Time: < 1 minutes

JavaScript Arrow Function

What Is Arrow Function ?

Arrow function is one of the features introduced in the ES6 version of JavaScript. It allows you to create functions in a cleaner and shorter way as compared to regular functions.

Syntax :-
(paraml, param2, paramN) => { statement(s) }

In fact, if you have only one parameter you can skip the parentheses () as well

const hello = name => "Hello" + name;

We can remove a return and { } bracket if the function have only single line statement

const hello = () => "Hello world"

If you have parameters, you pass them inside the parentheses ()

const hello = (name) => "Hello" + name;

Regular function

function hello() {
  return "Hello world";
}

Arrow function

const hello = () => {return "Hello world"}

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.