JS判断任何数据类型

 

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<script>

alert( deterType(12) );

function deterType(obj){
    var tmp = {}.toString.call(obj).split(' ')[1];
    
    tmp = tmp.substring(0,tmp.length-1);
    
    return tmp
};
</script>
</body>
</html>

 

posted @ 2016-04-19 15:59  __枫伊飘渺  阅读(211)  评论(0编辑  收藏  举报