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);
}
Posted in JavaScript |

Leave a Reply

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