title: Javascript String to Number type coercion
body: <p>I ran into this issue the other day and couldn't figure out what exactly is happening under the hood. What are the rules for coercion of a String into a Number type? and why does it fail in the instance of '5.0.1'?</p>
  
  <pre><code>var numStr = '5.0';
  var floatStr = '5.0.1';
  
  //Passes
  if (numStr &gt;= 4) {
      alert('5 &gt; 4');
  }
  
  //Fails
  if (floatStr &gt;= 4) {
      alert('5.0.1 &gt; 4');
  }
  
  console.log(parseInt(numStr)); //5
  console.log(parseInt(floatStr)); //5
  
  console.log(Number(numStr)); //5
  console.log(Number(floatStr)); //NaN
  </code></pre>