DEV Community

Sagar Gnawali
Sagar Gnawali

Posted on

Day 4 -> 40 days of code.

Arrow function
It's the shortest function which we can use in the JavaScript.
It's just simple like other function the only difference is it use => that's why we think it's complicated. In real it's the simplest way to declare a function in JavaScript.
Let's see what does it mean
Normal function.
eg.
function printdata(x)
{
console.log(x);
}
printdata('normal function');

On the other hand if we use arrow function it's looks like this
eg.
const printdata = (x)=>
{
console.log(x);
}
printdata('arrow function');

Just do some task using arrow function like factorial of a number , basic calculation by passing parameters eg. Adding, multiplication. Then you will get to know more about this function.

Top comments (0)