best way to test if a variable is an array
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1058427/how-to-detect-if-a-variable-is-an-array">How to detect if a variable is an array</a>  </p>
</blockquote>



<p>When I need to test if variable is an array (for example input argument in a function that could be object or array) I usually use this piece of code</p>

<pre><code>typeof(myVar) === 'object' &amp;&amp; myVar.length !== undefined;
</code></pre>

<p>Is this the correct way or is there a more efficient way, considering that even if  <code>myVar instanceof Array</code> <a href="http://jsperf.com/js-array-test" rel="nofollow">is faster</a> it should be avoided due to <code>iframe</code> problem?</p>
