1、使用取余运算符(%) + 判断对象是否是数字来判断:
注意:空字符串、字符串类型数字、布尔true、空数组对1求余,结果都是true(因为他们都是对象,),所以要先判断对象是否为数字
var isYear=function(year){
if(typeof(year)==="number"&&year%4===0){
console.log("true")
}else{console.log("false")}
}
isYear(2012) 成功打印出true或者false
2:使用Math.round、Math.ceil、Math.floor判断,整数取整之后还是自己
var t=2000
console.log(Math.round(t)===t)