cannot read property
// That is mostly because the object was not declared until the moment when the code ran,
// Example:
console.log(object.list.map(el => el.name))
const object = {
list: [
{name: 'test'},
{name: 'second'}
]
}
// The error happens because the object was created after the map call
// The same happens if you forgot to import a package for example.
// If you are dealing with a situation that you don't know if the object
// has an specific property, you can use a question mark to tell the compiler
// that maybe the property doesen't exists, returning undefined:
console.log(object.default.size) // error
console.log(object.list[1]?.age) // undefined
console.log(object.default?.color) // undefined