JavaScript’s Option Chaining Operator, Explained

Simplify Your Code with One of JavaScript’s Newest Features

Stop me if you’ve encountered this problem before:

You’re coding in JavaScript and want to access a property of a property of an object — let’s say a song object has an artist attribute, and that artist has a name. Like this:

let artist = {
name: "Elvis Presley",
albums: [
{
title: "Elvis Presley",
year: 1956,
chartPosition: 1
},
{
title: "Elvis",
year…