当前位置: 代码迷 >> Web前端 >> 判断变量是不是是日期类型
  详细解决方案

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

热度:73   发布时间:2012-10-06 17:34:01.0
判断变量是否是日期类型

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"

  相关解决方案