TypeError: у null/undefined нет свойств
Исключение JavaScript "null (или undefined) has no properties" возникает при попытке получить доступ к свойствам null и undefined. У них их нет.
Сообщение
TypeError: Cannot read properties of undefined (reading 'x') (V8-based) TypeError: Cannot destructure 'x' as it is undefined. (V8-based) TypeError: Cannot destructure property 'x' of 'y' as it is undefined. (V8-based) TypeError: null has no properties (Firefox) TypeError: undefined has no properties (Firefox) TypeError: undefined is not an object (evaluating 'undefined.x') (Safari) TypeError: Right side of assignment cannot be destructured (Safari)
Тип ошибки
Что пошло не так?
Как null, так и undefined не имеют свойств, к которым вы могли бы получить доступ. Следовательно, вы не можете использовать аксессоры свойств для них или деструктурировать их.
Примеры
У null и undefined нет свойств
null.foo; // TypeError: null has no properties undefined.bar; // TypeError: undefined has no properties
См. также
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_properties