Vullnetarët tanë s’e kanë përkthyer ende në Shqip këtë artikull. Merrni pjesë dhe ndihmoni të mbarohet kjo punë!
Mund ta lexoni artikullin edhe në English (US).


ReferenceError: reference to undefined property "x" (Firefox)

Error type

(Firefox only) ReferenceError warning which is reported only if javascript.options.strict preference is set to true.

What went wrong?

The script attempted to access an object property which doesn't exist. There are two ways to access properties; see the property accessors reference page to learn more about them.


Invalid cases

In this case, the property bar is an undefined property, so a ReferenceError will occur.

var foo = {};; // ReferenceError: reference to undefined property "bar"

Valid cases

To avoid the error, you need to either add a definition for bar to the object or check for the existence of the bar property before trying to access it; one way to do that is to use the Object.prototype.hasOwnProperty() method), like this:

var foo = {};

// Define the bar property = 'moon';
console.log(; // "moon"

// Test to be sure bar exists before accessing it

if (foo.hasOwnProperty('bar')) {

See also

Etiketa dhe Kontribues Dokumentesh

Kontributorë te kjo faqe: arai, fiejen, nmve, Sheppy, fscholz
Përditësuar së fundi nga: arai,