34
loading...
This website collects cookies to deliver better user experience
=
an opening and closing parenthesis ( )
which will denote the function, leading with an arrow =>
which is nothing but an equal sign and angular bracket. =
sign leading with =>
arrow and the statement you want to return.( )
in which we will pass our parameters.this
keyword and scoping of variables, let me show you how.setTimeout
to make a block of code so that we can see the scope of this
keyword using arrow functions v/s regular function.Here we will receive the name(Shreyas) and age(18) in the arrow function, as inside this function this
keyword will use the scope where it was created ( i.e. inside the class ) but on the other hand the regular function will use the scope where it is invoked or called i.e. which is outside the class and since there is no name and age defined outside the class, we will receive undefined
.