When I try to debug this code (http://jsfiddle.net/QWFGN/)
var foo = (function(numb) {
return {
bar: function() {
debugger;
return "something";
}
}
})(1);
foo.bar()
Developer tool in Chrome behaves differently than and Firebug in Firefox and developer tool in IE. The issue is that variable numb is not visible in Chrome developer tool on the debugger; line. But, it is visible in Firebug and IE. If I try to type numb in Chrome's console I get:
ReferenceError: numb is not defined
numb, of course, is visible in this closure, and if I change code to (http://jsfiddle.net/QWFGN/1/)
var foo = (function(numb) {
return {
bar: function() {
debugger;
console.log(numb);
return "something";
}
}
})(1);
foo.bar()
numb is now visible in Chrome as well and I can get value 1 as a response.
So, My question is: Why only Google Chrome doesn't see closure variables that are never used? Does Google Chrome have it's own implementation of Garbage Collection, or is it only related to implementation of debug tool in Google Chrome.