Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
How does jquery ready function allow it's first parameter to become jquery object?

Today I stumbled upon this:

jQuery(document).ready(function($$){
    console.log($$);
});

Apparently, $$ is considered as the jQuery object itself. Usually to do such a thing, we need to pass the jQuery variable:

(function($$){
    console.log($$);
}(jQuery))

But in case of ready function how does it know $$ is the jQuery object? I think jquery defines the ready function under the hood in a way that passes it's first parameter as jQuery.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is described in the docs.

In this situation:

jQuery(document).ready(function($$){
    console.log($$);
});
  • When the jQuery script tag runs, window.jQuery has jQuery assigned to it
  • jQuery(document) references that global identifier
  • jQuery.ready`'s callback, as designed, calls its callback with the jQuery object

This functionality doesn't have much use unless you're using jQuery.noConflict, but for another example of something similar:

theLibrary().ready(function($$){
    console.log($$.libraryProp);
});
<script>
// library example
window.theLibrary = Object.assign(
  // the library is both a function
  () => ({
    ready: (callback) => {
      callback(window.theLibrary);
    }
  }),
  // and an object with properties
  {
    libraryProp: 'libraryProp'
  }
);
</script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!