Before explain Arrow function you should learn EcmaScript(6)
and learn about that.So.. I just explain a little about that: is a JavaScript standard intended to ensure the interoperability of web pages across different browsers.
well, now we arrived to ArrowFunction.
as you know ecmaScript has multiple versions, in last version(5) arrowFunction was somthing like that:
const function1 = function(x, y) {
return x * y;
}
But in the next version arrowFunction in ecmaScript changed:
const function1 =(x, y)=> x * y;
so whenever you see this symbol =()=>
in javaScript its mean Arrow Function!!
this is very important topic in java script, if one day you want to learn React
you need to know what is arrowFunction and how should use from it.
as you see, we declare a variable with const and gave a name to it and then after equal symbol
=
we gave our arguments in the parentheses and use from this=>
, after this line we just return our output, remember this, it doesn't matter to usereturn
word or not, but in React!! is so important.
Top comments (4)
All you need to see is:
=>
- it is the arrow from which 'Arrow functions' get their name.Also, the arrow function has never changed. Your first example shows a function expression, not an arrow function.
hmmm, this is new topic for me, thank you.
Great article
thank you!!!