javascript variable's weird behaviour : <p>Case 1 - If I console.log(variable) before the variable declaration I get undefined. eg;</p>

<pre><code>  // code 
  console.log(a);
  var a ;

  // output
  undefined
</code></pre>

<p>Case 2 - If I console.log(variable) without variable declaration I get  Uncaught ReferenceError: variable is not defined. </p>

<pre><code>// code
console.log(a);

// output
Uncaught ReferenceError: a is not defined
</code></pre>

<p>But incase of functions we can call a function before or after function definition it never give any issue. eg;</p>

<pre><code>  console.log(example());

  function example(){
    return 'test done';
  }
  console.log(example());

 // output without any issue
</code></pre>

<p>Now My question is, what is the difference between <strong>undefined</strong> and <strong>not defined</strong>.</p>
