Get rid off null checks in Javascript 2019

Manivannan Baskaran
1 min readMar 20, 2019

When I tried to update my knowledge on javascript, I have gone through a wonderful thing in javascript.

Have you ever had the problem of accessing nested object property, something like this?

Doing this way is tedious in case of complex data structures. To get rid of this, javascript is introducing a new concept call optional chaining and works as follows.

optional chaining in javascript

this makes more easy, readable and simple. isn’t it?

Note: Currently, optional chaining is not part of the official spec, but is at stage-1 as an experimental feature. You have to add @babel/plugin-proposal-optional-chaining in your babelrc to use it.

--

--

Manivannan Baskaran

I'm an always optimistic, open minded and knowledge seeking fullstack developer passionate about UI/UX and changing things for the better :)