JavaScript Exceptions best practices?
<p>I'm starting to learn JavaScript, so far no problem but I have a hard time finding a good explanation of the Exception mechanism in JS.</p>

<p>It seems similar to C++, JS allows to throw about every object, instead of just throwing an Exception object (probably due to it's dynamic nature).</p>

<pre><code>throw 'An error occured.';
</code></pre>

<p>works, as well as</p>

<pre><code>throw new Exception('An error occured.');
</code></pre>

<p><code>catch</code> and <code>finally</code> both seem to work like their Java equivalent. Still, I don't know what are widely accepted best practices regarding exceptions.</p>

<p>So, for example, is it legit to throw objects of type string, like:</p>

<pre><code>throw 'An error occured';
</code></pre>

<p>How would I differentiate between different types of exceptions?</p>
