O'Reilly logo

Rediscovering JavaScript by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Limitations of Arrow Functions

Due to their concise and expressive nature, we’ll be tempted to use arrow functions rather than anonymous functions. However, the choice should not be due to infatuation. Learning about the limitations of arrow functions will help us make an educated choice between anonymous functions and arrow functions.

Only Anonymous

Named anonymous function sounds like an oxymoron, but a function created in the argument list of a method call may be given a name. Here’s an example of naming a function that’s created just in time in the argument list.

 setTimeout(​function​ repeat(count) {
  console.log(​'called...'​);
 if​(count > 1)
  setTimeout(repeat.bind(​null​, count - 1), 1000);
 }.bind(​null ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required