IE中的unknown类型

image

  <script type='text/vbscript'>
	<!--
	Function vbTest()
		MsgBox("Hello World!")
	End Function

	vbTest()
	-->
  </script>

  <script type='text/javascript'>
	alert(typeof vbTest);	
  </script>

如果在type这段script内有vbTest的JavaScript函数声明,那么typeof得到的将会是function,vbscript中的vbTest将会被覆盖。

下面的代码也将得到unknown

<script type="text/javascript">
if(typeof window.ActiveXObject != "undefined"){
 oXMLHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");
 alert(typeof oXMLHTTPRequest.abort);
}
</script>

IE中xml类型得通过typeof 得到是date

规范中关于typeof的定义,请查阅下面的地址了解更多:

https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/typeof_Operator

其中

image

以及ECMA-262 section 11.4.3

原文地址:https://www.cnblogs.com/meteoric_cry/p/1833813.html