Ext JS中的typeOf:以字符串格式,返回给定变量的类型

其中对字符串对象、元素节点、文本节点、空白文本节点判断并不准确

测试代码如下:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>Ext.typeOf</title>
<link rel="stylesheet" type="text/css" href="js/ext4/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="css/icon.css">
<!--<script type="text/javascript" src="js/ext4/bootstrap.js"></script>-->
<script type="text/javascript" src="js/ext4/ext-all-debug.js"></script> <script type="text/javascript" src="js/ext4/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
Ext.onReady(_pageLoaded); /**
* 页面加载完毕后执行的函数
* @private
*/
function _pageLoaded(){
function _fn() {
}
var obj = {name:'pine',age:28};
var arr = [1,2,3];
var reg = /^123$/;
var element = document.getElementById('table1');//元素节点
var node1 = document.getElementById('node1').firstChild;//文本节点
var node2 = document.getElementById('node2').firstChild;//空的文本节点 console.info(" Ext.typeOf(undefined):%s",Ext.typeOf(undefined));
console.info("*Ext.typeOf(null):%s",Ext.typeOf(null)); console.info(" Ext.typeOf(字符串):%s",Ext.typeOf('123'));
console.info(" Ext.typeOf(数字):%s",Ext.typeOf(123));
console.info(" Ext.typeOf(布尔):%s",Ext.typeOf(true));
console.info("*Ext.typeOf(字符串对象):%s",Ext.typeOf(new String('123')));
console.info("*Ext.typeOf(数字对象):%s",Ext.typeOf(new Number(123)));
console.info("*Ext.typeOf(布尔对象):%s",Ext.typeOf(new Boolean(true))); console.info("*Ext.typeOf(日期):%s",Ext.typeOf(new Date()));
console.info(" Ext.typeOf(函数):%s",Ext.typeOf(_fn));
console.info(" Ext.typeOf(对象)%s",Ext.typeOf(obj));
console.info("*Ext.typeOf(数组):%s",Ext.typeOf(arr));
console.info("*Ext.typeOf(正则):%s",Ext.typeOf(reg)); console.info(" Ext.typeOf(dom元素):%s",Ext.typeOf(element));
console.info(" Ext.typeOf(dom文本节点):%s",Ext.typeOf(node1));
console.info(" Ext.typeOf(空的dom文本节点):%s",Ext.typeOf(node2)); }
</script>
</head>
<body>
<table id="table1">
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
<span id="node1">测试文本~~~</span>
<span id="node2"> </span>
</body>
</html>
05-11 11:23