Generator

Did you know that you can read content offline by using one of these tools? If you would like to read offline MDN content in another format, let us know by commenting on Bug 665750.

Dash App

Table of Contents

  1. Summary
  2. Syntax
  3. Methods

Summary

Lets you work with generators.

Syntax

function fibonacci(){
	var fn1 = 1;
	var fn2 = 1;
		while (1){
			var current = fn2;
			fn2 = fn1;
			fn1 = fn1 + current;
			yield current;
		}
	}
 
var it = fibonacci();
var it2 = (i * 2 for (i in it));

Methods

For methods available on Generator instances, see Methods of Generator instances.

next
send

Tags (3)