r/javascript • • Feb 20 '18

Optional Chaining may be coming to JavaScript

https://dev.to/sammyisa/optional-chaining-may-be-coming-to-javascript--4ff0
321 Upvotes

100 comments sorted by

View all comments

27

u/beforan Feb 20 '18

So glad to see this. I adopted the c# equivalent so fast when it came out. Plus we use Babel in our workflow where I work so I guess I can use this right now!

11

u/vinnl Feb 20 '18

Plus we use Babel in our workflow where I work so I guess I can use this right now!

But if syntax changes or it even never makes it to the standard as well, you will have to update your codebase.

9

u/[deleted] Feb 20 '18

Small price to pay. In-fact you could probably codemod it out if needs be.

10

u/vinnl Feb 20 '18

If such a codemod is available/you're able/willing to write it yourself. In any case, it's a good thing to be aware of before blindly adopting it - I'm afraid many people aren't afraid what "stage 1" means.

0

u/[deleted] Feb 20 '18

[deleted]

3

u/vinnl Feb 20 '18

Hehe :)

1

u/alchemoria Feb 20 '18

Your slashes are confusing

2

u/vinnl Feb 20 '18

Sorry I know, I wasn't up to spending more time on reworking that comment :P

1

u/beforan Feb 20 '18

Definitely a valid point

1

u/[deleted] Feb 20 '18

Pretty sure this one will stick:

  • solves a common pain point

  • makes sense in both OO and functional contexts

  • similar syntax is present in multiple languages

  • transpiration produces very little ES5, so it is likely that the engine makers won't have too hard a job to implement it.

2

u/vinnl Feb 21 '18

Those are all very good points in favour of adopting it now - very helpful for people wanting to weigh their options to see whether it's worth it to them.

(Apart from you probably meaning to refer to transpilation :P)

1

u/[deleted] Feb 21 '18

Autocorrect never fails to amuse :)