Optional chaining (obj?.param1?.param2
) seems to be a great feature and I really wanted to see it implemented and finally get rid of nested ifs, arbitrary functions and what not for such a simple operation.
But there's a problem, it doesn't work. I updated to Node 12 and I still get an error:
var dude = res?.param?.params[0]
SyntaxError: Unexpected token '.'
or
var dude = res.param?.params[0]
SyntaxError: Unexpected token '.'
What is the problem?
Do I need to change some language config or download a library to enable this feature? Or is it simply not out yet?