When you want to reach a property of an object, usually you can use
&& operator to avoid getting errors when the object is null or undefined.
const city = user && user.address && user.address.city;
You can just use
?. instead of adding
&& operator for each level of the tree.
Code above can be written as:
const city = user?.address?.city;
If user or address is undefined or null, then the value of city become undefined.
If you want to experiment this feature, you can use this Babel plugin.
Another new feature I liked is Nullish Coalescing feature. It is kind of a complementary feature for optional chaining and also planned to be released in ES2020.
You can also read this post in my blog.