Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda