Javascript: the most efficient way to check if a variable is a function, an array or a object
<p>Let's suppose we have a variable that could be a function, object or array.</p>

<p>I want to find the most efficient way to determinate it.</p>

<p>I think the following way is not optimized because if I know that <code>isFunction = true</code> I don't want to calculate the other variables (isArray, isObject);</p>

<p>What is the order to calculate them, which optimize the resources, 
by using the ternary operation?</p>

<pre><code>var isFunction,
    isArray,
    isObject;

var obj = function () {};

isFunction = (typeof obj === "function") ? true : false;
isArray = (obj.length &gt; 0) ? true : false;
isObject = (typeof obj === "object") ? true : false;

console.log(isFunction , isArray , isObject ); // true, false, false (the good way)
console.log(isFunction , isArray , isObject ); // true, undefined, undefined
</code></pre>
