Write more reliable JavaScript with optional chaining

June 19, 2025

A laptop with a blank screen sits on an outdoor desk during sunset. To the left is a mesh pencil holder with pens and pencils, and to the right is a smartphone with a charging cable. A railing and soft sunlight in the background suggest a relaxed, open-air workspace.

Let me know if this sounds familiar: you’re deep into debugging or trying to access a deeply nested property in a JavaScript object. Suddenly you see this classic error:

TypeError: Cannot read property ‘x’ of undefined

This is a common pain point, especially when working with API responses, optional fields, or dynamic data structures.Fortunately, JavaScript has a powerful feature to help with this: optional chaining (?.). Optional chaining has saved me from more than a few headaches, and I’m willing to bet it’ll do the same for you.

Source: Write more reliable JavaScript with optional chaining – Matt Smith

JavaScript has all kinds of features that many developers may not have heard off–and we love to hp surface those here at Conffab!

Optional chaining I one such feature, that Matt smith explores here.