title: Easy way to check if a variable is a string?
body: <p>This question is a spin-off of <a href="https://stackoverflow.com/questions/12254658/is-an-instance-of-array-but-isnt-of-string">[] is an instance of Array but &quot;&quot; isn&#39;t of String</a></p>
  
  <p>Given that</p>
  
  <pre><code>"" instanceof String; /* false */
  String() instanceof String; /* false */
  new String() instanceof String; /* true */
  </code></pre>
  
  <p>and</p>
  
  <pre><code>typeof "" === "string"; /* true */
  typeof String() === "string"; /* true */
  typeof new String() === "string"; /* false */
  </code></pre>
  
  <p>Then, if I have a variable <code>abc</code> and I want to know if it's a string, I can do</p>
  
  <pre><code>if(typeof abc === "string" || abc instanceof String){
      // do something
  }
  </code></pre>
  
  <p>Is there a simpler, shorter and native way of doing this, or must I create my own function?</p>
  
  <pre><code>function isStr(s){
      return typeof s === "string" || s instanceof String;
  }
  if(isStr(abc)){
      // do something
  }
  </code></pre>