r/node • • Nov 10 '20

Conditionally call a function with optional chaining.

Post image
345 Upvotes

126 comments sorted by

View all comments

58

u/dudeitsmason Nov 10 '20

Just because you can, doesn't mean you should

7

u/nickbreaton Nov 10 '20

In think case, why not do this if you’re in an environment that supports it? If this was in the language all along, I imagine it would be the established way for doing this.

4

u/conventionalWisdumb Nov 10 '20

Agreed. Ruby has a similar operator and the issues others have raised here never come up.