title: Best practice for declaring empty javascript variables
body: <p>Is there something like a best practise when it comes to declaring variables in javascript before assigning a value to them? Sometimes it's necesary for scope reasons, but what if scope doesn't matter?</p>
  
  <pre><code>// Declare first
  (function() {
      var foo = 'bar',
          a = 500,
          b = 300,
          c;
  
      // Some things get done here with a and b before c can use them...
  
      c = a * b;    
  
      // c is now ready to use...
      doSomething(c);
  }());
  
  // Declare when needed
  (function() {
      var foo = 'bar',
          a = 500,
          b = 300;
  
      // Some things get done here with a and b before c can use them...
  
      var c = a * b; 
  
      // c is now ready to use...
      doSomething(c);
  }());
  </code></pre>
  
  <p>And I'm also wondering what's best practise for something similar with object literals:</p>
  
  <pre><code>// Add property with null assigned to it
  var myObj = {
      foo: null,
  
      doSomething: function() {
          this.foo = 'bar';
      }
  };
  
  // Property gets added when value is set
  var myObj = {
      doSomething: function() {
          this.foo = 'bar';
      }
  };
  </code></pre>