title: Why should I use string.length == 0 over string == "" when checking for empty string in ECMAScript?
body: <p>Most of the developers on my current project use a (to me) strange way to check for empty strings in ECMAScript:</p>
  
  <pre><code>if (theString.length == 0)
      // string is empty
  </code></pre>
  
  <p>I would normally write this instead:</p>
  
  <pre><code>if (theString == "")
      // string is empty
  </code></pre>
  
  <p>The latter version seems more readable and natural to me.</p>
  
  <p>Nobody I asked seemed to be able to explain the advantages of version 1. I guess that at some time in the past somebody told everybody that this is the way to do it, but now that person left and nobody remembers why it should be done this way.</p>
  
  <p>I'm wondering whether there is a reason why I should choose the first version over the second? Does it matter, is one version better than the other one? Is one version safer or faster for some reason?</p>
  
  <p>(We actually do this in Siebel eScript which is compliant with ECMAScript Edition 4)</p>
  
  <p>Thanks.</p>