Examples
setTimeout
ES6
Best practices
Prefer arrow functions as callbacks
As callbacks, arrow functions have two advantages over traditional functions:
this
is lexical and therefore safer to use.- Their syntax is more compact. That matters especially in functional programming, where there are many higher-order functions and methods (functions and methods whose parameters are functions).