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

221
Views
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 answers
Answer question

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 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!