-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
  • 9,427
  • 12
  • 41
  • 67

1 Answers1

0

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

DhruvPathak
  • 40,405
  • 15
  • 109
  • 170