DEV Community

loading...

Discussion on: How to use the ?. operator in Javascript

Collapse
harken24 profile image
Jozo

It's not, it's part of the ES2020 :)
freecodecamp.org/news/javascript-n...

Collapse
salyadav profile image
Saloni Yadav

developer.mozilla.org/en-US/docs/W...

I saw it here and since it’s documented here, assumed it’s already present. I see the document was updated only recently and the cross browser stability has still not kicked in.
However I was able to use this in Typescript with es6 build (babel with backward compatibility) atleast 6-8 months back. Queer!

Thread Thread
kenbellows profile image
Ken Bellows • Edited

Usually when I read "ES6 build" it means it transpiles to ES6 code, rather than that it is already ES6 compatible. This operator, fortunately, is super easy to transpile back to older syntax, so Typescript has supported it (and the nullish coalescing operator) for a little while now

(Edit for tone, and to add some details)

Thread Thread
salyadav profile image
Saloni Yadav

This puts a lot of things into perspective! :) Thank you!