2

Is it possible that by calling one function I can get the return of function called inside?

function f1(...){
   f2(...);
}

function f2(...){
   return 123;
}

In other words by calling only f1() can I get 123 from f2 return?
I hope it makes sense.

Thanks in advance.

EDIT

I probably didn’t make the best analogy here so this is my code:

    getLocation(45.123,12.123);

function getLocation(a,b) {
  document.write(lo);
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(p){ajmo(p,a,b);});
  }
}

function ajmo(position,a,b) {
  lat = position.coords.latitude;
  lng = position.coords.longitude;
  alert('kurac:' + getDistanceFromLatLonInKm(a,b,lat, lng));
}


function getDistanceFromLatLonInKm(lat_origin, lon_origin, lat_pos, lon_pos) {
  var R = 6371;
  var dLat = deg2rad(lat_pos - lat_origin);
  var dLon = deg2rad(lon_pos - lon_origin);
  var a = 
    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
    Math.cos(deg2rad(lat_origin)) * Math.cos(deg2rad(lat_pos)) * 
    Math.sin(dLon / 2) * Math.sin(dLon / 2)
    ; 
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  var d = R * c;
  return d;
}

function deg2rad(deg) {
  return deg * (Math.PI/180)
}

I want to access d from return of function getDistanceFromLatLonInKm just by calling get.Location.Is it possible in this case?