Safely access nested properties of an object without verbose checks.
Optional chaining is a modern JavaScript feature that simplifies the process of accessing properties deep within a chain of nested objects. Before optional chaining, if you wanted to access a property like `user.address.street`, you had to ensure that `user` and `user.address` were not `null` or `undefined` to avoid a `TypeError`. This often led to verbose and repetitive code, like `if (user && user.address) { ... }`. The optional chaining operator, `?.`, provides a clean solution to this problem. Instead of causing an error if a reference in the chain is `null` or `undefined`, the expression short-circuits and evaluates to `undefined`. So, you can write `user?.address?.street`. If `user` is `null` or `undefined`, the expression immediately returns `undefined` and `address` is never accessed. If `user` exists but `user.address` is `null` or `undefined`, it also returns `undefined`. Only if the entire chain of properties exists will it return the value of `street`. This operator can also be used with function calls (`myFunc?.()`) and array access (`myArray?.[0]`), making it a versatile tool for writing more resilient and readable code when dealing with data whose structure is not guaranteed.