Coding / Programming Videos

Post your favorite coding videos and share them with others!

Javascript Generators (ES6/ES2015) – Brandon Courtney – Medium

Source link

TL;DR:

  • Basic example (demonstrated with iteration)
  • Properties
  • Methods
  • Using “return” with Generators
  • Passing arguments
  • Generators with ES6katas
  • Summary

Basic example (demonstrated with iteration)

Repl.it link

Generators with ES6katas

Least intimidating possible way to start exploring:

http://es6katas.org/

Summary

Generators return an object like this { value: 10, done: false } every time they encounter a yield statement. It returns done: true AFTER the last yield, OR when a return statement is returned.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

A generator function returns a Generator object which conforms to both the iterable protocol and the iterator protocol. — MDN

**Disclaimer**

This is intended firstly as notes/future reference for myself. Secondarily for others, and lastly as a tutorial. For these reasons I’ve decided upon the following conventions:

  • Absolute minimization of text (particularly non-code text)
  • Skip an introduction — if an overview is needed in one of my posts always skip down to the summary

While a wider audience is not my main aim, I also hope this explanation provides helpful insight to those who do stumble across this. I maintain these conventions in all posts/videos I create.

Source link

Bookmark(0)
 

Leave a Reply

Please Login to comment
  Subscribe  
Notify of
Translate »