ES6 iterator 和 generator

ES6 iterator 和 generator

ES6 introduces a new mechanism Iterator iterator traversal data. It is an interface that provides a unified mechanism to access a variety of different data structures. Any data structure as long as the deployment Iterator interface, to complete traversal operation (i.e., sequentially processed all members of the data structure). Based iterator mechanism, ES6 provides many new operator, for example for of, and deconstruction, expand the operator and the like.
Generator is an asynchronous programming solutions ES6 provided, similar to other languages coroutine. It is a function can be aborted during execution, then come back to continue, rather than a one-time executed. Generator function returns an execution visitor object, that is, in addition to a function Generator state machine, or a visitor object generating function. Returning visitor object, may in turn through each state inside Generator function.
This article

Guess you like

Origin yq.aliyun.com/articles/717391