Why is jQuery's $.type() defined to return "object" instead of "error" for native ECMAScript Error objects?
<p><strong>Update:</strong> I have created a ticket: <a href="http://bugs.jquery.com/ticket/12191" rel="nofollow">http://bugs.jquery.com/ticket/12191</a></p>

<hr>

<p>jQuery's <a href="http://api.jquery.com/jQuery.type/" rel="nofollow"><code>$.type()</code></a> function returns the <code>[[Class]]</code> internal property (lower-cased) of an object. E.g.:</p>

<pre><code>$.type( {} ) // "object"
$.type( [] ) // "array"
$.type( function () {} ) // "function"
</code></pre>

<p>However, it only works for these types of objects: </p>

<pre><code>Boolean Number String Function Array Date RegExp Object
</code></pre>

<p>specified by this section of jQuery's source code:</p>

<pre><code>// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
    class2type[ "[object " + name + "]" ] = name.toLowerCase();
});
</code></pre>

<p>In addition to those types of objects, the ECMAScript standard defines corresponding <code>[[Class]]</code> internal properties for these:</p>

<pre><code>Arguments Error JSON Math
</code></pre>

<p>This is specified in this sentence of the ECMAScript standard (in <a href="http://ecma-international.org/ecma-262/5.1/#sec-8.6.2" rel="nofollow">section 8.6.2</a>):</p>

<blockquote>
  <p>The value of the [[Class]] internal property of a host object may be
  any String value except one of "Arguments", "Array", "Boolean",
  "Date", "Error", "Function", "JSON", "Math", "Number", "Object",
  "RegExp", and "String".</p>
</blockquote>

<p><code>$.type</code> returns <code>"object"</code> for those types of objects:</p>

<pre><code>$.type( new Error ) // "object"
$.type( JSON ) // "object"
$.type( Math ) // "object"
(function () { $.type( arguments ); /* "object" */ }())
</code></pre>

<p>instead of <code>"error"</code>, <code>"json"</code>, <code>"math"</code>, and <code>"arguments"</code>, which are the actual <code>[[Class]]</code> values here (capitalized).</p>

<p>I would like to make it clear that <code>$.type</code> could return those correct values if it wanted to, since it uses the <code>Object.prototype.toString.call()</code> retrieval method, which returns <code>"[object Error]"</code> for <code>Error</code> objects, for instance.</p>

<p>So, why does jQuery report <code>"object"</code> instead of those four values? I could understand <code>JSON</code> and <code>Math</code>, since those are not instances, but singleton objects. And I could even understand <code>arguments</code>, since that is an automatically provided object, instead of an instance explicitly created by a JavaScript program (as in <code>var args = new Arguments;</code>). Buy why errors? I don't see what makes <code>Error</code> objects special (compared to the other native types, like <code>Date</code>, <code>Array</code>, etc.). </p>

<h2><strong>tl;dr</strong></h2>

<pre><code>$.type( new Error ) // why does this return "object" instead of "error"?
</code></pre>

<hr>

<p><strong>Update:</strong> Just to clarify one thing: I know why <code>$.type</code> returns <code>"object"</code> for <code>Error</code> instances, as I have looked into its source code, and found the code that is responsible for this behavior. I would like to know why <code>$.type</code> is defined to behave in such a manner.</p>
