What is typeof “unknown”?

Yesterday when I was testing an AJAX script in an application I’m working on, I wanted to use the abort() method of the XmlHttpRequest object to cancel current outstanding data transfers (if this is all Greek to you, don’t worry, one day I will write more about AJAX).

IE unexpectedly threw errors when I was trying to use that method, and it did as well when I tried to use object detection to check for it. Weird. So I resorted to use typeof to check what it returned, and to my amazement it returned “unknown”! To my knowledge, the only valid and possible values in JavaScript to get when using the typeof operator are these:

  • number
  • string
  • boolean
  • object
  • function
  • undefined

So is this is an IE bug? Or some freaky ActiveXObject hocus pocus? Please let me know if you have any idea!

Code to test with:

// Note! This code will only work in Internet Explorer
if(typeof window.ActiveXObject != "undefined"){
	oXMLHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");
	alert(typeof oXMLHTTPRequest.abort);


  • Mats says:

    Maybe it's related to the "not implemented yet" type … 😉

    I don't remember when I ran across it but I remember seeing it on one occasion.

  • Rowan Lewis says:

    I wish I could help, but I can't :/

    The reason I'm posting this is the ad under the article, it says:

    "INSTANT DOWNLOAD ! – Download right now!"

    Perhaps you should change ad provider…

  • Jens Wedin says:

    I know this does not have anyting to do with the article but I clicked the download now link. haha, what a joke, nice stealing from mozilla.org

  • Peter Leing says:

    Peter-Paul Koch had done some work with aborting XMLHTTP requests back in September. Maybe it will help you.

    XMLHTTP notes: abort() and Mozilla bug

  • Peter Leing says:

    Unless it is like Mats says, it may be a bug then. Microsoft’s MSDN docs on Jscript only list the 6 typeof values you state.

    JScript .NET typeof Operator

    JScript typeof Operator (JScript 5.6)

    I also tried the type of .open and .send and got the same ‘undefined’ message back. It may just be that trying to get the typeof from an ActiveXObject’s Method is not supported or working.

  • Robert Nyman says:


    Yes, it sounds like a "not implemented" thing, I've seen that one too.

    Rowan, Jens,

    Yeah, maybe I should change ad provider… 🙂

    And yes, that web site looks pretty darn similar to the Mozilla web site.


    Yes, I've read that article, which is very good. And I guess his conclusion is right, that it's only necessary to abort calls in Mozilla.

    Anyway, it doesn't explain Microsoft's own interpretation of what <code>typeof</code> can return… 🙂

  • Johan says:

    Maybe it is a syntax error

    typeof window.ActiveXObject != "undefined"

    rewrite as (boolean operator):

    typeof window.ActiveXObject !== undefined

  • Robert Nyman says:


    Yes, maybe just a bug. However, the <code>open()</code> and <code>send()</code> methods do work, even though they also return typeof "unknown", as opposed to the <code>abort()</code> method that throws an error.



    Thanks for the idea, although the line that goes wrong is when I want to check for support for the <code>abort()</code> method.

  • Vojtech says:

    I met the "unknown" type when debugging one script working with an X3D Player. I had to write something like this:


    function test(value)


    if ((typeof value == "object") && (value == null)) {value = "null";}

    if (typeof value == "undefined") {value = "really_undefined";}

    if ((typeof value.toString == "undefined") || (typeof value.toString == "unknown")) {value = "no_toString";}

    return value + ":";



    Without the third "if" I got "undefined" (no colon).

  • sudhakar says:

    I also found that IE returns 'unknown' when using 'typeof'.

    It seems to happen in the following case:

    Add html form elements (such as textboxes, drop down lists etc.) to a container (such as a div) dynamically using javascript and then reset container's innerHTML to empty (div.innerHTML = '').

    Repeat this again, this time selecting enabling/disabling a few of the html form elements.

    Next when you again add form elements to the DIV and try to access these elements by javascript, IE returns 'unknown' when using 'typeof'.

    I believe this has got some thing to do clearing these elements from IE's DOM. Apparently setting innerHTML = '' does not seem do this as IE could not figure out using 'typeof'.

  • Tom Trenka says:

    Internet Explorer displays “unknown” when the object in question is on the other side of a COM+ bridge. You may not know this or realize this, but MS’s XMLHTTP object is part of a different COM+ object that implements IUnknown; when you call methods on it, you’re doing so over a COM bridge and not calling native JavaScript.

    Basically that’s MS’s answer if you try to test or access something that’s not a true part of the JScript engine.

    Before you complain about it further, bear in mind that MSXML was designed to be used from any MS platform, including VB and C++; there are methods and properties on XMLHTTP that are useless in scripting and even cause some confusion (such as the much maligned onreadystate, which makes plenty of sense once you realize that MSXMLHTTP, when used from C++ and VB, give you full interactive access to the internal IStream via the responseStream property.)

  • Robert Nyman says:


    Thanks for sharing!



    Tom Trenka,

    Very interesting reading. However, it seems that that can't be applied to everything, given sudhakar's example above.

  • fornetti says:

    I do not believe this

  • Michael says:

    Ran into the same issue today. Thanks for the post. My interpretation of ‘unknown’ is this:
    – the ActiveX control loaded
    – the method requested is exposed as an interface
    – the type of this interface is non-javascript, and thus unknown to javascript
    – the output of this interface is unknown to javascript, it will just try to convert the data when it receives it, defaulting to string


  • Robert Nyman says:


    Thanks for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.