Generators in JavaScript Explained
In this tutorial we will look iterators and generators.
– We understand iterators in JavaScript
– Look at a new property called symbol.iterators
– Look at practical use of iterators.
#javaScript #generators #interators
*My Udemy Courses
https://www.udemy.com/js-masterclass/
https://www.udemy.com/course/react-hooks-course/
Follow me for technology updates
* https://facebook.com/techsith
* https://www.facebook.com/groups/techsith
* https://twitter.com/techsith1
* https://www.linkedin.com/groups/13677140/
* https://medium.com/@patelhemil
Help me translate this video.
* https://www.youtube.com/timedtext_cs_panel?c=UCbGZKLIHpox2l0whz6_RYyg&tab=2
Note: use https://translate.google.com/ to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.
Original source
36 responses to “JavaScript Generators Tutorial”
Super Straight forward and highly simple to understand explanation of generator functions on the entire YouTube, great job !
Impressed and subscribed just after this one.
Great work. Thank you so much. 馃檪
Very well explained, thank you!
great tuto
Thx
Thank you for your great videos! I would like to see a course from you about design patterns like the observer, singleton patterns and generaly how to structure efficiently and DRY an application by real world examples in react or vanilla js! Greetings from Greece!
Very nice !馃憤
Nice and clean. Great video, thank you
I struggle to imagine a real world use case for this. The example you gave at the end could just as easily have been accomplished using async/await which would also be more readable and require fewer lines of code.
Beautiful
Very well explained. Everytime I need to learn something about javascript I know I can come to your channel and find it! 馃檪
Really awesome
You explain this perfect! going to use it in Israel to explain my students and also giving your videos!!
Hi TechSith….I just want to say…I love watching your tutorials…very nice explanation with real-time example… really it's helping us a lot….
What is the real life example of generators
Hi, thanks for your tutorial, but I have one question. This generators practical example with promises… why should I use generators instead of .then in Promises. It works the same :).
Regards!
this guy is awesome.
Great, thank you!
We can do same with promises using async await then what is the difference?
Hi Sir,
For the last example you gave:
function *generator(){
yield request('url1');
yield request('url2');
}
This is an easier version for .then callback? Are there any differences between using .then and this method? Thank you for your video!!
Thank you so much for your tutorials. Came for the memes, stayed for the dreams.
Thanks for the wonderful explanation.
excellent
Could you also illustrate on passing an argument into the generator function via ".next(argument)"? I am very confused about this.
Thanks. I wanted to learn Iterators and Generators so I could use Mongorito which makes extensive use of yield statements in its API.
As an added bonus, I now know how to make my code cleaner with Generators.
@techsith: Awesome! thank you for the video.
Why can't I just do this?
let iterator = i[Symbol.iterator]().next() //this just stays at array[0]
Instead of console.log(iterator.next()) everytime?
should I learn Angular2 or React?!! I'm so torn, help!
I have a doubt in generator example using promise : For this specific example of generator with promise, it seems i can do the such dependent url calls using only promise so that 2nd url call will happen until first finishes and use 1st url data in 2nd, so why do we use generator here ? Please correct me if i am wrong. Thanks for such excellent tutorials !
please put this video after iterators tutorial in advanced javascript tutorial;
also your channel is awesome, it covers a lot of things I was looking for after going from absolute basics to more advanced things – you explain them really straightforwardly
iterators and generators might be just what I was looking for – I've got
reocurring problem with iterate through arrays using for loop, and getting
expected value after every iteration (not just when value of "i" reaches
it's limit) – I have to write function for every case.
let iterator = i [ Symbol.iterator ]() ;
why wrapping Symbol.iterator within third brackets [ ] ?
awesome videos man, thanks!!
keep up the good work 馃檪
Hi, your videos are very useful.
I got corrected with the navigation menu issues.
Thanks for your reply. Can you post some video for google map placing in a website javascript code?
nice
Thanks! very useful!
btw, why can I use "let iterator = i.Symbol.iterator()" and have to use let iterator = i[Symbol.iterator]()
it gives error "VM257:1 Uncaught TypeError: Cannot read property 'iterator' of undefined
at <anonymous>:1:24"