let thing = obj?.node?.thing ?? 2
?., and nullish coalescing,
The final stage is stage 4. That's where optional chaining and nullish coalescing are now. Proposals in this stage are considered adopted! They're part of a dynamic ECMAScript version referred to as ESNext. ESNext includes features that are set to be part of the next release. ECMAScript releases occur yearly and include all the Stage 4 proposals from the previous year. For example, ES2019 was released in June 2018.
However, a feature reaching Stage 4 doesn't necessarily mean you can use it yet. If you want to include bleeding-edge syntax you'll want to understand how the ECMAScript standard is adopted and supported.
Your best chance at being able to use a brand new Stage 4 proposal (or even an earlier stage if you want to provide feedback) is to include the Babel plugin in your project. Why Babel?
Because each engine is written to match the ECMAScript standard, the engine itself determines what syntax you can use in your project. And each target environment has its own engine! What browser is your user accessing your site on? What engine is in that browser? Does that engine support the syntax you're trying to use in your code?
There are multiple projects across the web dedicated to keeping an updated compatibility table. These tables track available compilers/polyfills, browsers and node versions and match ECMAScript features to note whether they're supported.
There are also great sites like https://caniuse.com/
The compilers/polyfills section includes a handful of different technologies. Note that the Babel and Typescript columns include
core-js version is noted.
@babel/polyfillexists and uses
core-jsunder the hood. However, it was deprecated in favor of using
It'd be incredibly challenging to write code using syntax that was compatible with the lowest common denominator target environment. If that was the threshold then we wouldn't be able to use optional chaining for many years until all browsers in use supported it. Or we'd limit our users to only the very latest phones and/or browser updates. As you might suspect, developers don't want to do that.