Skip to content

Conversation

@DeeDeeG
Copy link
Contributor

@DeeDeeG DeeDeeG commented Jun 21, 2021

Hi folks. I noticed the "support" info box at the bottom of https://v8.dev/features/optional-catch-binding has the wrong NodeJS version listed. It should be Node 10, but it lists Node 8.

(Optional catch binding is an ECMAScript 2019 feature... V8 first added support for this feature in V8 version 6.6. Node didn't update its V8 engine version to 6.6 until Node v10.0.0.)

See:


When I do `node -e 'console.log(process.versions)' with the latest Node 8.x, latest Node 9.x, and Node 10.0.0, I get...

  node: '8.17.0',
  v8: '6.2.414.78',
  node: '9.11.2',
  v8: '6.2.414.46-node.23',
  node: '10.0.0',
  v8: '6.6.346.24-node.5',

Testing with the following file reveals that Node 10 supports optional catch binding, Node 8 and 9 don't.

// trycatch.js
try {
  throw new Error
} catch {
  console.log('Caught an error')
}

With Node 8 and 9, I get the following error:

$ node trycatch.js 
/home/[user]/trycatch.js:4
} catch {
        ^

SyntaxError: Unexpected token {

With Node 10 I get the catch block executing properly, indicating optional catch binding is working:

$ node trycatch.js 
Caught an error

Node 10 updated its copy of V8 10 V8 6.6, thereby adding support for
catch blocks with optional/no error binding.

Node 8 still has V8 engine version 6.2 or older.
@google-cla google-cla bot added the cla: yes label Jun 21, 2021
@mathiasbynens mathiasbynens merged commit b235045 into v8:main Jun 22, 2021
@mathiasbynens mathiasbynens added the language features Explainers for new JavaScript or WebAssembly features label Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes language features Explainers for new JavaScript or WebAssembly features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants