Home Flight manual Ramblings Tags RSS

Flight manual for javascript

JavaScript's generator function*

ECMAScript ("JavaScript" for the uninitiated)1 catches quite a bit of flak for numerous reasons online, but it can boast some truly spectacular expressiveness, possibly somewhat unmatched when paired with savvy TypeScript sauce that would make a Rustacean blush.

You've no doubt come across the destructuring syntax to effectively return multiple values from a single function, but we can do even better: we can return multiple times from the same invocation.

Possibly mad yet patently beautiful, let's explore the generator.

Continue reading →