variable being passed from nowhere to geo location function

variable being passed from nowhere to geo location function

I have always had a problem with understanding veriables that get passed from thin air and are not declared anywhere, see the below script for example, i can across it when i was trying to understand the geo location API:

  1. function geoFindMe() {
  2.   var output = document.getElementById("out");

  3.   if (!navigator.geolocation){
  4.     output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
  5.     return;
  6.   }

  7.   function success(position) {
  8.     var latitude  = position.coords.latitude;
  9.     var longitude = position.coords.longitude;

  10.     output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';

  11.     var img = new Image();
  12.     img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false";

  13.     output.appendChild(img);
  14.   };

  15.   function error() {
  16.     output.innerHTML = "Unable to retrieve your location";
  17.   };

  18.   output.innerHTML = "<p>Locating…</p>";

  19.   navigator.geolocation.getCurrentPosition(success, error);
  20. }
The above code can be seen HERE.

Now check out this below line:

  1. function success(position) {
Now who on earth is passing the position variable to success function ? this really baffles me, i have seen similar things when i use jQuery Ajax function. can somebody explain this concept of variables being passed from no-where ?