JS Built-ins
Generatorthrowbeginner

Generator: typeof throw is function

πŸ“– Usage Example
function* gen() {
  try { yield 1 }
  catch (e) { console.log(e.message) } // β†’ 'oops'
}
const it = gen()
it.next()
it.throw(new Error('oops'))

generator.throw() resumes the generator by throwing an error at the yield point, which can be caught inside the generator.

Check that typeof throw is function.