Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure I follow, JS doesn't have coroutines (generator functions can be used kind of like coroutines, but for example you can't resume them with an argument).


Yes it does:

  function* greeter() {
    const name = yield "What's your name?"
    yield `Hello, ${name}!`
  }
  const gen = greeter()
  
  console.log(gen.next().value)
  console.log(gen.next("Alice").value)


TIL!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: