title: how to know what is x when x maybe several type
body: <p>how to know what is x in js?</p>
  
  <p>sometimes I have to write an function with parameter which has several type. such as test(x); I need to know what is x before I run the code .</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="hello"&gt;hello&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  
      // the x var will be random 1 of 4 bellow , how to know what is it ?
      var x = $('.hello')[0];
      var x = ['1','2'];
      var x = {'name':'jimmy'};
      var x = 'hello';
  
      if(???){
          // alert x is a html node
      }
      if(???){
          // alert x is a js arr
      }
      if(???){
          // alert x is a js obj
      }
      if(???){
          // alert x is a js str
  }
  
  &lt;/script&gt;
  </code></pre>