title: How to make a javascript function to run after another one get finished?
body: <p>I'm using Apache Cordova to develop mobile application. the problem is that I want to get mobile phone number and then send it via jQuery get function for authorization. all functions are OK but the function that get mobile phone number is slower than other and it get finished last.</p>
  
  <p>a summary of my code is this :</p>
  
  <pre><code>document.addEventListener("deviceready", onDeviceReady, false);
  function onDeviceReady() {
      devicePhoneNumber();
      alert("ALERT1"); // ALERT1
  };
  function devicePhoneNumber() {
      var telephoneNumber = cordova.require("telephonenumber");
      telephoneNumber.get(function (result) {
      alert(result); //ALERT2
      }, function () {
          alert("error");
      });
  };
  </code></pre>
  
  <p>I don't know why first a get ALERT1 and after that i get ALERT2.
  I want to run my other codes after I get ALERT2.</p>
  
  <p>Any suggestion would be appreciated.</p>