What is difference between Arrow function and function? | Sololearn: Learn to code for FREE!

+11

What is difference between Arrow function and function?

I know the the syntax is differ from function but why we use arrow functions?

5/16/2020 12:52:20 PM

Shahghasi Adil 👑 🇦🇫

3 Answers

New Answer

+4

the biggest difference is that compared to a normal function, an arrow function does not have the following in its context: 1) 'this' keyword 2) arguments 3) 'super' keyword 4) new.target also the 'return' keyword can be omitted when not using curly braces: const sum = (a,b) => a + b; instead of: const sum = (a,b) => { return a + b };

+3

it is more succinct, that's why it is paired with other ES6 feature such as Array methods forEach, map, reduce, etc.

+1

Currying https://code.sololearn.com/cu2DKco5Ho8a/?ref=app