读书人

判断变量是不是是日期类型

发布时间: 2012-10-06 17:34:01 作者: rapoo

判断变量是否是日期类型

function testObjectType(val) {
var t;
switch(val) {
??? case null: t = "null"; break;
??? case undefined: t = "undefined"; break;
??? default:
??????? t = Object.prototype.toString.call(val).match(/object\s(\w+)/)[1];
??????? break;
}
return? t.toLowerCase();
}

?

?

如果是日期类型则返回值是"date"

读书人网 >Web前端

热点推荐