r/node • • Nov 10 '20

Conditionally call a function with optional chaining.

Post image
345 Upvotes

126 comments sorted by

View all comments

26

u/[deleted] Nov 10 '20

I think the latter solution is very readable and clear. This will be a very useful feature in React.

4

u/Guisseppi Nov 10 '20

Node has to wait for the V8 implementation, you can add this babel plugin and use it on the frontend now: https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining

3

u/[deleted] Nov 10 '20

Thanks, we will be waiting then!

3

u/[deleted] Nov 10 '20

CRA already has this babel plugin so you can use optional chaining right now.