title: Setting bool value to input and getting string type via javascript/jquery
body: <p>When I get a value or set a value (from the server side, for example) for an input that is a boolean type it comes as "True" or "False" instead of true or false.</p>
  
  <p>For example:</p>
  
  <pre><code>//"True"
  var isDated = $('.someClass').val();
  
  
  //will not pass because isDated is a string
  if (isDated == true){
      console.log("passed");
  }
  </code></pre>
  
  <p>Why does this happend?
  Which is the best way to avoid this?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've found a blog that has a solution to avoid this problem:
  <a href="http://www.peterbe.com/plog/data-and-attr-in-jquery" rel="nofollow">http://www.peterbe.com/plog/data-and-attr-in-jquery</a></p>
  
  <p>Below a prototype method called .toBoolean() to validate true/false when it comes as a string based on some responses from this post: </p>
  
  <pre><code>String.prototype.toBoolean = function ()
  {
      var dictionary = { "True": true, "False": false };
      return dictionary[this];
  };
  
  Boolean.prototype.toBoolean = function () {
      return this;
  };
  
  Number.prototype.toBoolean = function ()
  {
      if (this) {
          return true;
      }
  
      return false;
  };
  </code></pre>