javascript 发电机的快速示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 发电机的快速示例相关的知识,希望对你有一定的参考价值。

const testingTeam = {
  lead: 'Amanda',
  tester: 'Bill'
};

const engineeringTeam = {
  testingTeam,
  size: 3,
  department: 'Engineering',
  lead: 'Jill',
  manager: 'Alex',
  engineer: 'Dave'
};

function* TeamIterator(team){
  yield team.lead;
  yield team.manager;
  yield team.engineer;
  const testingTeamGenerator = TestingTeamIterator(team.testingTeam);
  yield* testingTeamGenerator;
}

function* TestingTeamIterator(team){
  yield team.lead;
  yield team.tester;
}

const names = [];
for (let name of TeamIterator(engineeringTeam)){
  names.push(name);
}

console.log(names);

以上是关于javascript 发电机的快速示例的主要内容,如果未能解决你的问题,请参考以下文章

javascript 返回发电机

javascript 发电机

javascript 配对发电机

javascript 发电机

javascript uuid发电机

javascript uuid发电机