Javascript Arrow Functions
Jun 30, 2021
First of all, I would like to say that the arrow function is the most helpful Arrow functions remove a lot of unnecessary boilerplate code surrounding a function definition. The key changes are as follows :
function
keyword is removed- function-name isn’t needed
return
the keyword is not needed{}
curly braces only needed for multiple line code- the
=>
replacesfunction
,{}
andreturn
keywords - Arrow syntax automatically binds this to the surrounding code’s context
Look at how the 4 line function is reduced to a 1-liner function.