How do I tell difference between object and string in javascript?
<p>I have a javscript function (actually a jQuery plugin) which I will want to call as either</p>

<pre><code>myFunction("some input");
</code></pre>

<p>or</p>

<pre><code>myFunction({ "prop": "value 1", "prop2": "value2" });
</code></pre>

<p>How do I, in the function, tell the two apart?</p>

<p>In other words, what should go in the <code>if</code> conditions below?</p>

<pre><code>if (/* the input is a string */)
{
    // Handle string case (first of above)
}
else if (/* the input is an object */)
{
    // Handle object case (second of above)
}
else
{
    // Handle invalid input format
}
</code></pre>

<p>I have jQuery at my disposal.</p>

<p><strong>Update:</strong> As noted in an answer, if the input is <code>new String('some string')</code>, <code>typeof(input)</code> will return <code>'object'</code>. How do I test for <code>new String('')</code>, so I can handle that the same way as <code>''</code>?</p>
