Optional chaining is currently not supported in Node.js version 13 and below. It will be supported from Node.js version 14 and most of the browsers as it is moved to Stage 4. Currently, few platforms are supporting it. You can find the list of platforms supporting optional chaining in the given link. You can enable optional using --harmony flag.

Answer from Balaj Khan on Stack Overflow
🌐
V8
v8.dev › features › optional-chaining
Optional chaining · V8
Optional deletion means that the ... version 80 · Firefox: supported since version 74 · Safari: supported since version 13.1 · Node.js: supported since version 14 ·...
🌐
GitHub
github.com › redis › node-redis › issues › 2119
Optional chaining only supported with node > 14 · Issue #2119 · redis/node-redis
May 4, 2022 - Optional chaining is only supported with node > 14, so this breaks code that is using node < 14.
Published   May 04, 2022
🌐
Azureossd
azureossd.github.io › 2022 › 09 › 06 › Nodejs-12-failing-by-Optional-Chaining
Node.js 12 applications failing by Optional chaining -
September 6, 2022 - Node.js version 14 has included Optional Chaining (?.) operator as part of the updates/hightlights, which enable JavaScript developers to read the value of a property located deep within a chain of connected objects without having to check that ...
🌐
Glitch
support.glitch.com › glitch help
How to use optional chanining in Node v14? - Glitch Help - Glitch Community Forum
March 23, 2020 - I use node v14 and it has optional chaining but glitch doesn’t let me turn it on so please add it asap
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › objects: the basics
Optional chaining '?.'
E.g. in user?.address.street.name the ?. allows user to safely be null/undefined (and returns undefined in that case), but that’s only for user. Further properties are accessed in a regular way. If we want some of them to be optional, then we’ll need to replace more .
Find elsewhere
🌐
cri.dev
cri.dev › posts › 2020-05-01-Optional-chaining-in-Node.js-14
Optional chaining in Node.js 14 and JavaScript - cri.dev
May 1, 2020 - A long awaited feature of the language and runtime has been released and is available in Node.js 14 (and modern browsers): Optional chaining!
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Optional_chaining
Optional chaining (?.) - JavaScript | MDN
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020. ... The optional chaining (?.) operator accesses an object's property or calls a function.
🌐
Reddit
reddit.com › r/node › is support for optional chaining on the way?
r/node on Reddit: Is support for optional chaining on the way?
October 28, 2020 -

A feature I've enjoyed in the latest version of JS (at least on the front end) is optional chaining. I find it to be reasonably elegant and time-saving. But it's not supported in Node yet, and I'm not sure the best way to investigate what is "in the works" when it comes to new Node releases.

So, to those who know this kind of stuff, is support for optional chaining on the way?

Thanks everyone. Node is #4 language in all of Kazakhstan.

🌐
Medium
osvaldo-gonzalez-venegas.medium.com › exploring-optional-chaining-in-nodejs-7d27189b7db5
Exploring Optional Chaining in NodeJs (?.) | by Osvaldo González Venegas | Medium
November 6, 2024 - In this case, if any part of the chain (such as user or settings) is absent, the expression returns undefined, and the fallback value of 'light' is used. Optional Chaining is also compatible with arrays, allowing you to check if an element at a specific index exists.
🌐
RunKit Discuss
discuss.runkit.com › bug reports
Optional Chaining - Bug Reports - RunKit Discuss
January 8, 2021 - After setting the node version to greater than 14, I am still getting Unexpected token errors when using ?.. Optional chaining was added to node in version 14, so it should work.
🌐
Ioannispoulakas
ioannispoulakas.com › 2020 › 10 › 18 › node-14-optional-chaining-and-nullish-coalescing
Node 14 - Optional chaining and nullish coalescing - Ioannis Poulakas
Node 14 is already released and will become the next LTS version during the last week of October 2020. Node 14 is coming with two long awaited JS features, optional chaining and nullish coalescing.
🌐
Reddit
reddit.com › r/node › weird quirk in node with optional chaining operator and method?
r/node on Reddit: Weird quirk in Node with optional chaining operator and method?
July 23, 2023 -

I have this line of code:

const writeVal = model.default?.({model, config}) || model.default;

model is an object Despite the optional chaining operator, this throws an error:

TypeError: model.default is not a function

What's odd is:

  • I can't replicate this when simulating that line directly in the terminal, via node -e "globalThis.foo?.("`

  • The error doesn't get thrown if I remove the argument destructuring, i.e. just do mode.default?.(model, config)

I'm on Node v16.14.2.

Is this a bug, or am I missing something?

🌐
npm
npmjs.com › package › @babel › plugin-proposal-optional-chaining
@babel/plugin-proposal-optional-chaining - npm
Latest version: 7.21.0, last published: 3 years ago. Start using @babel/plugin-proposal-optional-chaining in your project by running `npm i @babel/plugin-proposal-optional-chaining`. There are 1750 other projects in the npm ...
      » npm install @babel/plugin-proposal-optional-chaining
    
Published   Feb 20, 2023
Version   7.21.0
🌐
DEV Community
dev.to › laurieontech › optional-chaining-has-arrived-111l
Optional Chaining Has Arrived! - DEV Community
December 20, 2019 - If you're a fan of react it's now part of react scripts 3.3. And in the latest version of vs code it's supported ... Father | ex-Cloudflare ex-Clerk | Autistic | AF Veteran | Hardware | Camping & Hiking 🏕️ | Trekkie | D&D twitch.tv/jacobmgevans ...
🌐
Packt Publishing
hub.packtpub.com › javascript-will-soon-support-optional-chaining-operator-as-its-ecmascript-proposal-reaches-stage-3
JavaScript will soon support optional chaining operator as its ...
ES2019: What’s new in ECMAScript, the JavaScript specification standard Introducing QuickJS, a small and easily embeddable JavaScript engine Introducing Node.js 12 with V8 JavaScript engine, improved worker threads, and much more
🌐
DEV Community
dev.to › saranshk › using-the-optional-chaining-operator-in-javascript-2959
Using the optional chaining operator in JavaScript - DEV Community
March 23, 2021 - So, you might want to add a Babel plugin if you need to support that or older versions of browsers. For Node.js you need to bump to a Node 14 LTS release for this, as it isn’t supported in 12.x.