title: set timeout to when a variable is fully initialized in javascript
body: <p>I wrote a rough code that logs an integer from a local variable but I had to set a timeout for the program to log the variable because without a timeout the log runs before the variable is initialized my question is is there a way to set the timeout until once the variable is initialized because a set time like 3000 is in definitive the amount of run time might change. Thanks in advance.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var randomInt;
  
  function testFun() {
      randomInt = 10;
  }
  
  setTimeout(function(){ console.log("Number is " + randomInt) }, 3000);
  
  testFun()</code></pre>
  </div>
  </div>
  </p>