<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
var a=1;
var b=2.1;
var c=true;
var d="";
function isInteger(num) {
if (!isNaN(num) && num % 1 === 0) {
document.write('a是一个整型'+'</br>');
} else {
document.write('a不是一个整型'+'</br>');
}
} //封装函数
isInteger(a); //调用执行
function isFloat(num) {
if (!isNaN(num) && num % 1 !== 0) {
document.write('b是一个浮点型'+'</br>');
} else {
document.write('b不是一个浮点型'+'</br>');
}
}
isFloat(b);
document.write ('c的数据类型为'+typeof c,'</br>'+'d的数据类型为'+typeof d);
</script>
</body>
</html>