Javascript: Optional Chaining

Rating: 5

Optional chaining allows you to try to read a property of a value that may not have that property, short-circuiting if the property is not found.

Example

const decoded = jwt_decode(jwt);
const decodedEmail = decoded?.session?.identity?.traits?.email;
More Info