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 ...

Get Rediscovering JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.