Fichas
arrow f
Fichas del conjunto (5)
- 1syntaxislet func = (arg1, arg2, ...argN) => expression
- 2purpose of =>They are meant for short pieces of code that do not have their own “context”, but rather works in the current one.
There are situations where we need to write a small function, that’s executed somewhere else:
arr.forEach(func) – func is executed by forEach for every array item. setTimeout(func) – func is executed by the built-in scheduler.
It’s often we need to create a function and pass it somewhere. And in such functions we usually don’t want to leave the current context. - 3this keyword and =>arrow functions do not have their own this. The value of this inside an arrow function remains the same throughout the lifecycle of the function and is always bound to the value of this in the closest non-arrow parent function.
- 4new keyword and =>Arrow functions can’t run with new Not having this naturally means another limitation: arrow functions can’t be used as
constructors. They can’t be called with new . - 5—
Información
- Descripción
- arrow f Fichas sobre arrow f, creado por milly larcen el 14/04/2020.
- Creado por
- milly larcen
- Visitas
- 0
- Valoración