Does named closures pollute the global/window object?

According to this node style guide, giving closures a name is a good practice:

Right

req.on('end', function onEnd() {
  console.log('winning');
});

Wrong

req.on('end', function() {
  console.log('losing');
});

However, I'm used to thinking of the

function someName() { someStatements(); }

...syntax as something that creates a global variable, someName or window.someName for that function. Is this really a good practice, or is that a very bad style guide?

Although you will not have this problem with node:

named function expressions are bugged in Internet Explorer, and will pollute the window object, as explained here: http://kangax.github.com/nfe/ under "JScript bugs"

The (not so) funny thing is that they are created even within conditional blocks that are never executed, as in this example:

var f = function g() {
  return 1;
};
if (false) {
  f = function g(){
    return 2;
  };
}
g(); // 2

This has created a problem on a production site I worked with, where jQuery suddenly was replaced with something else ( https://dev.plone.org/ticket/12583 )

In node.js, what you describe does not pollute the global context.

Given:

function someName() { someStatements(); }

global.someName will be defined. The following however:

setTimeout(function someName() { someStatements(); }, 500);

Will not set global.someName.

It seems to be just a matter of aesthetics. I tested this with node.js v0.8.4, but the same behaviour should be present in most modern browsers.

You can't access anonymous function using name (if function has name). It would be accessible within function body. So it would not pollute the window object.

req.on('end', function onEnd() { 
  console.log(onEnd); //function body
}); 
console.log(onEnd); //ReferenceError: onEnd is not defined

The name of named closure is only accessible inside of this closure so it should never pollute global namespace. Normally you would use the named closure to create a recursive closure.