title: Difference between if (var.length >0){} and if (var){}
body: <p>In javascript is there a difference between using</p>
  
  <pre><code>if (foo.length &gt; 0) {
  //run code involving foo
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>if (foo) {
  //run code involving foo
  }
  </code></pre>
  
  <p>If so, could someone please explain the difference and an example where they would not be the same?</p>