typeOf函数加强版
[javascript]
//肥主流版本
function typeOf(o) {
var t;return (t = typeof(o)) == "object" ? o==null && "null" || Object.prototype.toString.call(o).slice(8,-1):t;
}
//和谐版本
function typeOf(o) {
var t;
if((t = typeof(o)) == "object"){
if(o==null) t = 'null';
else t = Object.prototype.toString.call(o).slice(8,-1);
}
return t;
}
//执行结果
typeOf("abc"); //string
typeOf(true); //boolean
typeOf(123); //number
typeOf([]); //array
typeOf({}); //object
typeOf(function(){}); //function
typeOf(new Date); //date
typeOf(new RegExp); //regexp
typeOf(Math); //math
typeOf(null); //null
[/javascript]