Let's look at some new features in JavaScript... More Info
Latest release is 11th Edition – ECMAScript 2020
null coalescing Syntax - 'nullish coalescing operator' is... const a = b ?? c; ... a = b, unless b is null or undefined, when a = c 'ternary conditional if operator' is... const a = test ? b : c ... a = c, unless test is true, when a = b 'logical or operator' is... const a = b || c; ... a = b, unless b is falsy (null, undefined, "", 0, NaN, false), when a = cMore Info
... means you don't have to check if each level
of an object exists before drilling in, if any
level fails the result is 'undefined'.
const person = { address: {postcode: blah} };
const postcode = person?.address?.postcode;
... returns undefined if 'person' missing or 'address'
missing or 'postcode' missing.
More Info