ES6 - based learning (21): Generator function

ES6 introduces new Generator function, you can yield keyword, pending the implementation of the stream function, provides the possibility to change the execution flow, providing solutions for asynchronous programming. Basic Usage

Generator function composition

Generator There are two common function part to distinguish:

  • First, in the back function, there is a * before the function name;

  • Internal function has yield expression.

Wherein * represents a function used Generator function, yield function used to define the internal state.

Guess you like

Origin www.cnblogs.com/donghuang/p/12514286.html