Modernizr starts with the following:
window.Modernizr = (function(window,document,undefined) { ...
…but why have window and document been passed as parameters? Is it something to do with differences between browsers? Or is it simply so the can’t be redefined?
The parameters when calling that function are the following:
(this, this.document)So it’s guaranteed that
windowis the global object,documentis the document object andundefinedis undefined.It also results in a small performance improvement; see Why does jQuery has a "window=this" at the very begining and say it would speed up references to window? for details