Possible Duplicate:
jQuery question: what does it really mean?
For example,
(function (exports, $, undefined) {
// Code goes here
}(window.Chat = {}, jQuery));
What is the point of passing in “undefined” especially when there isn’t a third parameter? I’ve seen this syntax in multiple places.
“Undefined”, for some reason, isn’t a protected keyword in JavaScript. If you try to compare something to
undefinedyou have no guarantee you’re not comparing to some variable namedundefined. The code you refer to is a trick to work around this stupid issue. The parameter is guaranteed to actually be undefined since it’s an immediately invoked function where the writer of the code knew they weren’t passing the third parameter, so it will be the realundefined.