I would like a null conditional operator and null coalescing operator.
return data?.error?.message ?? "no error";
Also pattern matching would be a big win.
return data?.error?.message ?? "no error";
Also pattern matching would be a big win.
https://github.com/tc39/proposal-optional-chaining
https://github.com/tc39/proposal-nullish-coalescing
Recently started using optional chaining in our codebase (via Babel 7) and it's great so far. Also gives us proper static typing safety unlike Lodash `get(...)`
let val = 0
val || 30 // 30
val ?? 30 // 0
The same goes for other falsy values.