DEV Community

loading...

Discussion on: Understanding Generators in ES6 Javascript

Collapse
tuanphungcz profile image
Tuan Phung ⚡️ Author • Edited

yes, we can! You need to any function there ;)

function greeting() {
  console.log("Hi, Antonio!")
}

function* avengersGenerator() {
  yield "Hulk";
  yield greeting()
  yield "Spiderman";
}