Join me for my session: Learn the Top 10 ECMAScript 2015 Features. I’ll cover the top 10 new features of ECMAScript 2015 and teach you how to use them by showing code examples:
There are many more cool features, but I can’t fit every cool ECMAScript 2015 feature in my 45-minute presentation, so I’m going to share ECMAScript 2015 Generators with you today.
Generators are simply subtypes of Iterators. They are a special kind of function that can be suspended and resumed, which is different than iterators.
Note the yield statements. They return a generator instance and move to the next yield when
next() is called.
The snippet for the Dice Generator has a while loop that won’t end. It can roll numbers between 1 and 6.
Generators are supported in most of the modern desktop browsers. See the ECMAScript Compatibility Table.
If you want to use it in production, you’ll need to use a transpiler like Babel, which provides a polyfill.
The new ECMAScript standard will help you write better code, and make it easier. For Sencha developers, we benefit by writing clean code in Sencha classes, controllers, models, etc. I hope you’re as excited about this preview as I am. To learn more about ECMAScript 2015, join me at SenchaCon. Register today.
You’ll have a chance to meet the Sencha product managers and engineers, and you can ask them everything you want to know. Join us in the Sencha Zone, located in the Community Pavilion.
Leave a Reply