repl.it
@anonymous/

MutedFatherlySuperuser

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function* g() {
  try {
    yield 1
  } catch (error) {
    console.error('inside generator', error)
  }
  yield 2
  return 3
}

const generator = g()
console.log(generator.next())
console.log(generator.throw('first error'))
try {
  console.log(generator.throw('second error'))
} catch (error) {
  console.error('outside generator', error)
}
console.log(generator.next())
node v10.16.0