"Cannot read properties of undefined (reading 'X')" in JavaScript — What It Means and How to Fix It

What the JavaScript error "Cannot read properties of undefined (reading 'X')" means and how to fix it.

Published October 29, 2026

"Cannot read properties of undefined (reading 'X')" is occurs when code tries to access a property on a value that is undefined.

Key points

  • Check the browser console's stack trace to find exactly which line and call triggered the error

Example

let obj;
obj.name  // TypeError: Cannot read properties of undefined (reading 'name')
More JavaScript articles