Hi,

I'm reading Mark Obcena's Pro Javascript with mootools and have found some 
code that doesn't seem to agree with what he's written. When I run the 
following code in Firebug, I get myFn defined in all scopes. Any comments?

var myFn = function(){
// reference the function
console.log(typeof myFn);
};
myFn(); // 'function'

// global scope
var createFn = function(){
// result function
return function(){
console.log(typeof myFn);
};
};

// different scope
(function(){
// put the result function of `createFn`
// into a local variable
var myFn = createFn();
// check if reference is available
myFn(); // 'undefined' - NO! This shows up as defined!
})();

Reply via email to