Arrow Function in Javascript
Posted by Vrushali Shinde
Posted on 13th Apr 2026 2:16 PM
( 10 min Read & 20 min Implementation )

#arrow-function #javascript
Article Outline

Hello readers,


I have been learning about JavaScript for the past few days, and in this blog i would like to discuss about arrow function in javascript which is quite a fast solution for many users in js.




What are JavaScript arrow functions?


An arrow function is a shorter way to write a function in JavaScript.


If you’ve ever seen code like this:

const add = (a, b) => a + b;

That’s an arrow function! Let’s break it down step by step in a simple way.


Traditional Function


The traditional function for arrow was:

function add(a, b)
{
return a + b;
}



Arrow Function

const add = (a, b) => {
return a + b;
};


And hey there is even more shorter way to write the function


const add = (a, b) => a + b;


Now you might ask for a basic syntax for arrow function, so here it is

const functionName = (parameters) => {
// code here
};



Adding up 2 number function


now lets see an example by adding two numbers

let sum= (a,b)=> {
return a+b
}
console.log(sum(5,8)) // this prints 13


lets do this in shorter way

let sum= (a,b) => a+b
console.log(sum(5,8)) // this prints 13



When to user Arrow function

Lets understand when we can use arrow functions


Use arrow functions when

  1. You want shorter, cleaner code
  2. You are writing simple functions
  3. You are working with arrays (map, filter, etc.)


When NOT to use arrow functions

  1. You need your own this (like in objects or classes)
  2. You are writing complex functions with lots of logic



Final Thoughts

Arrow functions make JavaScript code:

  1. Shorter
  2. Cleaner
  3. Easier to read

They are widely used in modern JavaScript, so learning them is very useful!



All Comments ()
Do You want to add Comment in this Blog? Please Login ?