Skip to main content

Command Palette

Search for a command to run...

Arrow Functions in JavaScript: A Simpler Way to Write Functions

This blog explains arrow function syntax, parameters, implicit vs explicit return, and practical examples to help beginners write modern and readable JavaScript code.

Updated
3 min read
Arrow Functions in JavaScript: A Simpler Way to Write Functions

Modern JavaScript introduced arrow functions to make writing functions shorter and cleaner.

If you're learning JS, arrow functions will quickly become your favorite feature.

Let’s understand them step by step.

❋ What Are Arrow Functions?

Arrow functions are a shorter way to write functions in JavaScript.

They were introduced in ES6 (2015) to reduce boilerplate code and improve readability.

Instead of writing:

function greet(name) {
  return "Hello " + name;
}

We can write:

const greet = (name) => {
  return "Hello " + name;
};

❋ Basic Arrow Function Syntax

Here is the general syntax:

const functionName = (parameters) => {
  // code
};
  • const → storing function in a variable

  • (parameters) → input values

  • => → arrow symbol

  • {} → function body


❋ Arrow Function with One Parameter

If there is only one parameter, you can remove parentheses.

Normal function:

function square(num) {
  return num * num;
}

Arrow function:

const square = num => {
  return num * num;
};

❋ Arrow Function with Multiple Parameters

If there are multiple parameters, parentheses are required.

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

Example:

console.log(add(5, 3)); // 8

❋ Implicit Return vs Explicit Return

This is the most powerful feature.

🔹 Explicit Return (using return keyword)

const multiply = (a, b) => {
  return a * b;
};

🔹 Implicit Return (no return keyword)

If your function has only one expression, you can remove {} and return.

const multiply = (a, b) => a * b;

JavaScript automatically returns the value.

That’s called implicit return.


❋ Basic Difference: Normal Function vs Arrow Function

Feature Normal Function Arrow Function
Syntax Longer Shorter
this behavior Has its own this Uses parent this
Hoisting Yes No
Beginner friendly Yes Yes

❋ Why Arrow Functions Matter

  • Less boilerplate

  • Cleaner callbacks

  • Perfect for array methods like:

    • map()

    • filter()

    • reduce()

  • Modern JavaScript standard


Want More…?

I write articles on blog.prakashtsx.com and also post development-related content on the following platforms:

JavaScript

Part 5 of 6

In this series of blogs I have written some interesting concepts related to JavaScript.

Up next

Array Methods You Must Know

Understanding Array Operations with Simple Practical Examples