title: Why I can't access variables from inside some functions (JavaScript)?
body: <pre><code>var myvar = "my value";
  
  (function() {
    alert(myvar); // undefined
  })();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>  var myvar = "my value";
    $.post( url,
    function( data ) {
      alert(myvar); // undefined
    });
  </code></pre>
  
  <p>and how can I solve this issue without storing this value in a hidden input or div or other html containers ??</p>