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?
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.