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

222
Visualizações
Can someone explain how this parameter is able to get a value?
getWeatherData();
function getWeatherData(){
        navigator.geolocation.getCurrentPosition((success) => {
            console.log(success)
        })
    }

It returns an object with lat, long and other info, but how? Success is literally a parameter and has no value, right? It's not defined anywhere and I didn't pass a value in when I invoked the function.

Can someone explain to me how this works?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Function parameters get values when the function is called.

You are passing a function (lets call it anon) as an argument to getCurrentPosition.

getCurrentPosition (which you did not write and which you are not looking at the source code of) or a function that it passes anon onto will, at some point, call it. At that point anon is passed arguments.

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