Yo ninjas, in this Ecmascript 6 tutorial I’ll introduce you to generators, and how we can use them to create what are essentially pause-able functions.

JavaScript generators can be used to good effect when writing asynchronous code.

+ Chrome Canary –
+ Brackets editor –
+ Babel –

You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress & more on the channel homepage…


========== JavaScript for Beginners Playlist ==========

============ CSS for Beginners Playlist =============

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – or

================== Social Links ==================

Twitter – @TheNetNinja –


  1. if you want to make let the last line of apple for not being executed so you must write yield-1;
    yield console.log("apple");//will not work because it is the last line and should be yield-1;
     function* gen() {
    yield-1; console.log("apple");
    let mygen = gen();;

  2. It seems Async/Await would fit better in this case. It's based off generators of course. I guess support was lacking back in 2016.

  3. well many thanks Shaun for your efforts .. I really learned a lot from you 🙂 thanks a lot
    I just noticed that almost no one explained to use Ajax with ECMAScript6 yet .. specially when dealing with Laravel not plain php
    I searched for that for long long time and didn't catch any real results.
    I know Jquery make it simple especially when making a post request but .. I wanna do that with ecma6 .. I feel ecma6 make it easy to understand and deal with when you are coming from backend programing languages which make me feel I don't need to use jquery that much as I feel more comfortable with ecma6.
    may you give advise about that ? or even lead me to a resource can be useful about that point ?
    many thanks again and please accept my best regards 🙂

  4. It would be great if you could do a video on how generators work within the JavaScript event loop. I feel like this is cheating the message queue but honestly I'm not 100% on how this even works.

  5. Just finished this the (sadly) last of your ES6 tutorials. You have a real gift for conveying these concepts, keep it up! Subbed, and will be checking out your other series.

  6. Top notch!! Thanks, I understand the generator itself but I didn't understand clearly until right now the use cases, and with this video, my brain just click!!! Thanks!! Now I can see the power of this thing!!

  7. I just watched 5 different videos on Generators. Most of them just showed a bunch of code that was doing something whatever api thing rambling on about asynchronous, api and what not. You just showed what a generator does with some absolute basic and familiar things on a low level. This way you didn't distract me from what a generator essentially does. For me this certainly was the best approach. Thank you very much. Well done!

  8. yes 2 things please refresh page show how it looks then describe how it works and 2nd share your code examples next time plz 😀 other than that great vid 😀


Please enter your comment!
Please enter your name here