The differences between arrow function and normal function
Majid Babaeifar
Posted on July 27, 2022
- In arrow function you can omit the curly braces and the
return
statement when the function is a 1 liner.
const myFunc = (a, b) => a + b
console.log(myFunc(1, 2))
// log : 3
- In arrow function when it has only 1 argument, parenthesis is optional
const myFunc = a => a*a
console.log(myFunc(3))
// log : 9
- In arrow function the
this
key word is automatically bound to the parent's context
this
refers to the object that is currently executing the function
💖 💪 🙅 🚩
Majid Babaeifar
Posted on July 27, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.