Hackforge Academy

Category: React • Beginner

Published on 18 Feb 2026

Explanation

#white-Arrow function is a shorter syntax for #white-writing #white-functions in JavaScript. It was introduced in ES6 #white-and uses the => symbol.

Code Example

const greet = () => {
  console.log("Hello World");
};

greet();

Explanation

#white-Arrow functions can take parameters. If #white-there is #white-only one parameter, parentheses are optional.

Code Example

const square = x => x * x;

console.log(square(5));

Explanation

#white-When there are multiple parameters, #white-parentheses are required #white-around them.

Code Example

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

console.log(add(10, 20));

Explanation

#white-Arrow functions can return values directly #white-without using #white-the return keyword if the function has a #white-single expression.

Code Example

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

console.log(multiply(3, 4));

Explanation

#white-If you use curly braces, you must #white-explicitly #white-use the return keyword.

Code Example

const subtract = (a, b) => {
  return a - b;
};

console.log(subtract(10, 5));

Explanation

#white-Arrow functions do not have their own this. #white-They inherit this from the surrounding lexical scope.

Code Example

function Person() {
  this.age = 0;

  setInterval(() => {
    this.age++;
    console.log(this.age);
  }, 1000);
}

new Person();

Want structured learning with real projects?

Join our Weekend Live Workshop and become job-ready faster.