function* generator() { yield 'hello'; yield 'world'; return 'ending'; yield 'continue'; } var hw = generator(); // 返回一个遍历器Iterator对象 console.log(hw.next()); console.log(hw.next()); console.log(hw.next()); console.log(hw.next()); console.log(hw.next()); console.log(hw.next()); console.log(hw.next()); // 作用 循环调用