Cannot read properties of undefined (JavaScript)
In short: An attempt was made to access a property of undefined or null.
In more detail: The browser names the property, for example “reading ‘length’”.
In Depth
Possible causes
- Data not loaded yet.
- Wrong name or path.
- Object was not created.
Solutions
- Use optional chaining (
obj?.name). - Check the value with
console.log. - Wait for loaded data (async/await).
See also: JS, TypeScript