DEV Community

Cover image for JavaScript Arrow Functions ( easy tutorial )
Roopam Gupta
Roopam Gupta

Posted on

1

JavaScript Arrow Functions ( easy tutorial )

Before ES6, Functions were written as :

greeting = function(){
      return "This is webdevprojekts!";
}
Enter fullscreen mode Exit fullscreen mode

With the introduction of Arrow Functions in ES6 :

greeting = () => {
      return "This is webdevprojekts!";
}
Enter fullscreen mode Exit fullscreen mode

Arrow Functions return value by default, thus it gets more shorter :

greeting = () => "This is webdevprojekts!";
Enter fullscreen mode Exit fullscreen mode

Arrow Functions with parameter :

if you have parameters, you pass them inside the parantheses :

greeting = (name) => "This is webdevprojekts!" + name;
Enter fullscreen mode Exit fullscreen mode

Arrow Functions with single parameter :

if you only have one parameter, you can skip the parantheses as well :

greeting = name => "This is webdevprojekts!" + name;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay