title: What's the difference between variable definition and declaration in JavaScript?
body: <p>Is this a variable <strong>definition</strong> or <strong>declaration</strong>? And why?</p>
  
  <p><code>var x;</code></p>
  
  <p>..and is the memory reserved for x after this statement?</p>
  
  <p>EDIT:
  In C extern <code>int x;</code> is a declaration, <code>int x = 5;</code> is a definition. What's the analog in JS? Wikipedia says a declaration allocates memory and the definition assigns a value to this allocated memory. </p>
  
  <p>SECOND EDIT: 
  I think the explanation of @Deryck sounds great, but there's some output that disagrees with his explanation:</p>
  
  <pre><code>&gt; var x;
  undefined
  &gt; x
  undefined // now it looks like x is defined to the value undefined
  &gt; y
  ReferenceError: y is not defined
  </code></pre>
  
  <p>If the <code>ReferenceError</code> output would say <code>y is not declared</code> it would make sense. But often I read that JS has two non-values: <code>null</code> and <code>undefined</code>. So <code>var x</code> would be a definition with the value <code>undefined</code>. </p>