{{jsSidebar("Errors")}}
Message
ReferenceError: reference to undefined property "x" (Firefox)
Error type
{{jsxref("ReferenceError")}} warning in strict mode only.
What went wrong?
There is access to an object property that does not exist. There are two ways to access properties, see the property accessors reference page for more details.
Errors about references to undefined properties occur in strict mode code only. In non-strict code, they are silently ignored.
Examples
Invalid cases
In this case, the property "bar" is an undefined property.
"use strict"; var foo = {}; foo.bar; // ReferenceError: reference to undefined property "bar"
Valid cases
To avoid the error, you need to make "bar" a defined property, or check if a "bar" property exists before using it (for example, with the help of the {{jsxref("Object.prototype.hasOwnProperty()")}} method).
"use strict"; var foo = {}; foo.bar = "moon"; console.log(foo.bar); // "moon" if (foo.hasOwnProperty("bar") { console.log(foo.bar); }