Ads

Javascript 3 - Regular Function vs Arrow Function

Hello All, Myself Chakrapani Upadhyaya, Full Stack Engineer, In this article we will learn the differences of function and Arrow Function.

It is very interesting topic and asked in many interviews regarding JavaScript.


Arrow functions is a shorter and more predictable way to define functions in JavaScript, and it was introduced in ECMAScript 6 (ES6) to make code writing easier and more readable.

In simple word,

arrow function allows us to write functions in a shorter and cleaner way compared to regular functions.

Here is the simple example...

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

var result = add(10,20);

console.log(result);

And Here is the arrow function

//Arrow function
let add = (a,b) => a+b;

let result = add(10,20);

console.log(result);



Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !