Hi I am getting an uncaught reference exception on my code.This is what I have:
var config = {
debug: true,
data: {
debug: false,
logErrorsOnServer: true,
defaultCulture: '',
serviceUrl: ''
},
init: function(options) {
if (!options) {
return;
}
if (options.hasOwnProperty('debug')) {
data.debug = options.debug;
}
},
};
When I try to get the value of data.debug I get an uncaught reference error that says:
UncoughtReference Error: data is not defined
Whay can't I acces my data object?
dataas far as I can see. If you want to to access thedataproperty of theconfigobject, you have to useconfig.dataorthis.data, assuming you call the function withconfig.init(). JavaScript doesn't have any hidden magic like Java wherethis.is implicit (and that's a good thing). It does exactly what you tell it to do (most of the time).