第二行console yield后面的是一个普通对象,直接打印出了这个对象的字面量形式第三行console yield后面是一个迭代器对象,为什么仅仅打印出了 “{}”function* anotherGenerator(i) {yield i + 1;}function* generator(i){yield i + 10; yield {X:1}; yield anotherGenerator(i); yield*anotherGenerator(i);}var gen = generator(10);console.log(gen.next().value); //20console.log(gen.next().value); //{X:1}console.log(gen.next().value); //{}console.log(gen.next().value); //11
添加回答
举报
0/150
提交
取消