BRAHMA TECHNOLAB

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"}

LET’S DISCUSS YOUR PROJECT

Comments are closed.

Snehal

Typically replies within a day

Hello, Welcome to BRAHMA TECHNOLAB. Please click below button for chatting us through Skype.