JS Tutorial



JS ARROW FUNCTION


JavaScript Arrow Functions ➡️

Arrow Functions are a shorter syntax for writing function expressions in JavaScript. They were introduced in ES6 and are especially useful for writing concise code.

🧱 Basic Syntax

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

// Arrow function
const addArrow = (a, b) => a + b;

console.log(addArrow(3, 4)); // 7

📌 One-Line Functions

If the function body has a single expression, you can omit the return and curly braces:

const square = x => x * x;
console.log(square(5)); // 25

🧠 No `this` Binding

Arrow functions do not have their own this. They inherit it from the parent scope, making them great for callbacks.

📊 Interactive Example

🚫 Arrow Function Limitations

  • No own this
  • No arguments object
  • Cannot be used as constructors (no new)
Tip: Use arrow functions for short, clean functions especially inside array methods and callbacks!

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review