-1

Why do we use like this?

(function( $, window, document, undefined ) {
.......
})(( jQuery, window, document );)

I think the $ is converted to jQuery, Ok! But why window, document?

And also, can I use my own selector method something like this?

var mydiv = $('#mydiv');    
(function( $, window, document, mydiv, undefined ) {
    .......
    })(( jQuery, window, document, mydiv );)
Navin Rauniyar
  • 10,127
  • 14
  • 45
  • 68

1 Answers1

0

To make a locally scoped reference to window and document. This provides performance benefit.

DhruvPathak
  • 42,059
  • 16
  • 116
  • 175