Cannot read property of undefined
The most common error in JavaScript, and what it's really telling you.
The symptom
Cannot read properties of undefined (reading 'name'), or undefined is not a function, or the Python equivalent, 'NoneType' object has no attribute.
What it means
You have a thing you expected to exist, and it doesn't. Note carefully which part is undefined — in user.profile.name, the error naming name means profile is undefined, not name.
That distinction is where people lose time. The error names the property being read; the problem is the object it was read from.
Where the undefined came from
An async result you didn't wait for. The data arrives later; your code ran now. Missing await is the single biggest cause.
A find or lookup that matched nothing. array.find() returns undefined when nothing matches, and nothing warns you.
A typo in a key. response.data when the API returns response.results.
An element that isn't in the DOM yet. Script running before the markup it targets.
An API returning a different shape on error. Your success path assumes fields that an error response doesn't have.
The fix
Find the origin, don't patch the symptom:
Error: <paste the full error> Code: <paste the function and the lines above it> Don't add optional chaining to make it go away. Instead: 1. Which specific value is undefined? 2. Trace back — where should it have been set, and why wasn't it? 3. Is this an async problem, a lookup that found nothing, a wrong key, or an error-shaped response? 4. The fix at the origin. 5. What check would make this fail with a clear message instead of this one?
Optional chaining isn't a fix
user?.profile?.name stops the crash and gives you undefined further downstream, where it's harder to diagnose. It's right when the value is legitimately optional. It's wrong when the value should have been there — then you've hidden a real bug.
Log the whole object one line above the error. Nine times out of ten you immediately see it's an error response, an empty array, or a different shape than you assumed.