Hacker News new | past | comments | ask | show | jobs | submit login

I just want to have ? Functionality in js like Ruby...

So I can do

let name = obj?.data[i]?.name;

And not get error can't read property data of undefined, when there is something wrong, just have undefined as value.

To fix this I've to write redudant checks for each level of nested property. Or do stuff like (obj || {}).prop....




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: