了解
- JavaScript的Generator只有调用next()才执行以后yield的代码
- yield只能呈现的Generator函数外面,不然会报错
- yield表达式如果用在另一个表达式之中,必须放在圆括号外面console.log('Hello' + (yield 123))
- next办法能够带一个参数,该参数就会被当作上一个yield表达式的返回值
- for…of循环能够主动遍历 Generator 函数运行时生成的Iterator对象,且此时不再须要调用next办法
参考资料
- https://blog.csdn.net/qq_4500...
- https://www.runoob.com/w3cnot...