Horje
What is () => in JavaScript ?

In JavaScript, () => is the syntax used to declare an arrow function. Arrow functions provide a concise and more readable way to write function expressions. The () => syntax is used to define a function without the need for the function keyword.

Example: Here, add and addArrow are equivalent functions that take two parameters (a and b) and return their sum.

Javascript

// Regular function expression
const add = function (a, b) {
  return a + b;
};
 
// Arrow function equivalent
const addArrow = (a, b) => a + b;
 
console.log(add(3, 5));      // Output: 8
console.log(addArrow(3, 5)); // Output: 8

Output

8
8



Reffered: https://www.geeksforgeeks.org


JavaScript

Related
What is the pop() method used for in JavaScript Arrays ? What is the pop() method used for in JavaScript Arrays ?
What is the use of the push() method in JavaScript Arrays ? What is the use of the push() method in JavaScript Arrays ?
What is the use of fill() method in JavaScript Arrays ? What is the use of fill() method in JavaScript Arrays ?
What is the use of the every() method in JavaScript Arrays ? What is the use of the every() method in JavaScript Arrays ?
How to Convert an Array to a String in JavaScript ? How to Convert an Array to a String in JavaScript ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12