I'm setting a breakpoint in the code below where it says "breakpoint". Also adding a watch expression for dataStore.
function(){
var self = {};
var dataStore = [];
var areEq = UNAB.objectsAreEqual;
self.put = function(key, value){
/*breakpoint*/ dataStore.push({key:key, value:value});
}
return self;
}
At this breakpoint, Firebug tells me "ReferenceError: dataStore is not defined". Same results with trying to examine "areEq". However, dataStore.push executes without error. An additional strangness: adding a watch expression for "self" shows not the self object I expect, with one property, "put", but the "window" object.
Any idea what the heck is going on?
I think this is a firefox bug. If you set a breakpoint on var dataStore = []; then continue, when hit the breakpoint in put(). you get a closure scope (in Firebug 1.6). That scope has dataStore and self. I think Firefox is optimizing the closure scope away, perhaps since the code is nonsense anyway: there is no way to access dataStore.
A complete test case will eventually appear at http://getfirebug.com/tests/script/stackoverflow/dataStoreIsNotDefined.html
see also https://developer.mozilla.org/en/DOM/window.self
Probably self
is getting resolved by Firebug and probably also by Firefox in the global scope as referring to the current window. If you choose a different name other than "self", your code should make everyone happy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With