title: How to check whether a string has whitespace at the beginning in javascript
body: <p>I have a string as bellow</p>
  
  <pre><code>var str = "  Hello";
  </code></pre>
  
  <p>I can get the first character of the string as</p>
  
  <pre><code>var the_char=str.charAt(0);
  alert(the_char)
  if(the_char === " "){
      alert("first char of the query is space");
      return;
  }
  </code></pre>
  
  <p>But the alert is not poping up.I want to pop up the alert if the first character of the string is a space.How can I do this?</p>
  
  <p>Thanks</p>