20

Going around Modernizr source code I have found strange thing:

window.Modernizr = (function(window,document,undefined) {

After that this function will be called with two arguments (this, this.document).

Why undefined is used here? Is it meaningful or it's just strange code-style?

Gleb M Borisov
  • 617
  • 3
  • 10

1 Answers1

23

Creates a local undefined in case someone redefines undefined somewhere in the scope chain.

Also provides a faster lookup since undefined is a global property, so the scope chain traversal is reduced.

user113716
  • 318,772
  • 63
  • 451
  • 440