title: making synchronous call to async function
body: <p>lets say i have this async functuin:</p>
  
  <pre><code>function fooAsync(){
    callSomeApi(some_args, callbackFunction(results){
      return results; //i want to return the results here after the api call.
    }
  }
  </code></pre>
  
  <p>i'm looking for a way to assign the return value from the prev function to a var and continue with the code only when i have this value.  </p>
  
  <pre><code>//some code here
  var foo = fooAsync();
  //some code here after getting back from the async function.
  </code></pre>
  
  <p>the problem is that foo will be undefined since javascript will return before the inner async api call will finish. I know i can use callbacks for that but i'm looking for a way to 'lock' the async function and resume back only when it got the result. That way i wont have to pass all the code after the async call as a callback.</p>
  
  <p>to make things short - how can i return value from async ajax call (in my case i call google maps api) in a regular sync way?</p>