0

I'm just getting started on the Module Pattern in JavaScript with this article.

I'm not understanding why there's 2 parameters in the first line but only 1 argument is being passed in at the very end, window.

(function(window, undefined) {
  //some code
})(window);

Why is undefined a parameter and where is it coming from?

inthenameofmusik
  • 617
  • 1
  • 4
  • 16
  • it's an old "optimization" pattern anyway, don't worry about it, but know that any formal parameter without an argument passed will be `undefined` inside. – dandavis May 13 '16 at 00:16
  • 1
    This explains it https://toddmotto.com/what-function-window-document-undefined-iife-really-means/ – Jasen May 13 '16 at 00:17

0 Answers0