Quite often, I define variables like so:
var something = (function () {
if (x) {
...
} else {
...
}
}());
A good deal of the time, I’ll use document inside that closure. Like, document.getElementById for example. Then, when I run it through JSLint, I get a bunch of errors that “document” hasn’t been defined. So then I do this:
var something = (function (document) {
if (x) {
...
} else {
...
}
}(document));
That makes it so that the error only shows up one time in JSLint, which makes me feel good. This is solely to satisfy my own personal tics. I know I shouldn’t code exactly according to what JSLint says, I know that it’s only a guide, blah blah blah.
My question is, are there any performance issues with doing this? With passing the document object to an anonymous function that’s only being executed once, immediately?