We've all been there: checking if (user && user.profile && user.profile.name) to avoid a crash. Modern JavaScript and TypeScript give us the ?. operator, which makes this much cleaner. Using user?.profile?.name will simply return undefined if any part of the chain is nullish, keeping your code readable and your console free of those pesky "cannot read property of undefined" errors.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)