2 Comments
User's avatar
Richard's avatar

One slight niggle: your first example changes the behaviour of the code.

In the "before" code, the console.log statement only executes if user?.profile?.address?.city is not null. In the "modern" code, it always executes, so your console could be filled with "null" logs.

JavaScript Development Space's avatar

if(user?.profile?.address?.city)...

;-)