Arrow Functions in JavaScript: A Simpler Way to Write Functions

I'm a Software engineer and recently graduated (2025) in computer engineering, I'm more into Fullstack Developement using Angular, Nodejs, Express js, Mongodb, currently getting my hands on React js and Next js. Connect me on Linkedin here: https://linkedin.com/in/amanpatel2529
Hey modern JS developers! 👋 If you’ve started exploring JavaScript written in the last few years, you've definitely seen these sleek little functions everywhere: () => { ... }. They're called arrow functions, and today, let's demystify them and see how they can make your code significantly cleaner and more readable.
Think of arrow functions as a concise shorthand for writing function expressions. They reduce boilerplate and align perfectly with modern JavaScript style. Trust me, once you get used to them, you’ll be using them constantly.
Let's dive in! Open your browser's console (F12, inspect -> console) and type along!
The Boilerplate reduction
First, let’s see the dramatic difference in conciseness. Imagine we need a simple function to multiply two numbers.
Normal Function Expression:
JavaScript
const multiply = function(a, b) {
return a * b;
};
console.log(multiply(3, 4)); // 12
Arrow Function:
JavaScript
const multiplyArrow = (a, b) => {
return a * b;
};
console.log(multiplyArrow(3, 4)); // 12
Look at that! We dropped the function keyword and replaced it with a sleek => after the parameters. So much less to type, right?
Parameters: Shorter Still
Arrow functions offer even more shortcuts depending on how many parameters you have.
One Parameter: If you only have one parameter, you can actually omit the parentheses around it!
Normal:
const double = function(n) {
return n * 2;
};
Arrow (Simpler):
const doubleArrow = n => {
return n * 2;
};
See? n => { ... }. Parentheses are optional when there's exactly one parameter. Pretty cool!
Multiple Parameters: For multiple parameters, you always need the parentheses.
Normal:
const add = function(num1, num2) {
return num1 + num2;
};
Arrow:
const addArrow = (num1, num2) => {
return num1 + num2;
};
No Parameters: If you have zero parameters, you just use empty parentheses.
const sayHello = () => {
console.log("Hello there!");
};
sayHello();
Implicit Return vs. Explicit Return
Now for the real game-changer: implicit return.
An explicit return is when you use braces {} and the return keyword. (Like all our examples above).
const multiplyArrow = (a, b) => {
return a * b; // explicit return
};
An implicit return allows you to ditch the braces and the return keyword if your function body is just a single expression! The result of that expression is automatically returned.
Let's look at that multiply function again...
Implicit Return (Cleanest):
const multiplyImplicit = (a, b) => a * b;
That’s it! From 3-4 lines down to one, and it is incredibly readable. No function, no braces, no return. Wow.
Think about our greeting example...
Implicit Greeting:
const greet = name => `Hello, ${name}!`; // using template literals - sleek!
console.log(greet("Aman")); // Hello, Aman!
Isn't that beautiful and concise? Emphasize readability, indeed!
Basic Difference: Arrow vs. Normal Functions
Beyond syntax, there are a couple of key differences, but we’ll keep it simple for now:
Brevity: Arrow functions are dramatically shorter, especially for single-expression functions, thanks to implicit returns.
Context (
this): Avoiding deep discussion initially as suggested, arrow functions handle thethiskeyword differently. They don't create their ownthiscontext; instead, they inheritthisfrom their enclosing scope. For now, just appreciate that this makes them excellent for certain situations (like callbacks within methods) but less suitable for others (like object methods that need their ownthis). Regular functions are still your go-to when you need a specificthiscontext or more complex functionality like theargumentsobject.
Emphasize Readability & Modern Style
The primary reason arrow functions are so popular is that they just read better, especially once you get familiar with the syntax. Think about passing short callback functions to array methods – arrow functions shine here! The code is less cluttered, making the logic much more apparent. It's simply the way modern JavaScript is written.
👨‍💻 Your Turn: The Assignment!
Ready to put your knowledge into practice? Open your console and give this a shot:
Write a normal function to calculate the square of a number.
Now, rewrite that square function using an arrow function. Try to make it as concise as possible using implicit return!
Create an arrow function that returns whether a number is even or odd (Hint: use the ternary operator
? :for conciseness and implicit return!).Use an arrow function inside
map()on an array of numbers to create a new array where all the numbers are tripled.
Give it a go and see how much cleaner your code looks. Happy coding!




