1 { 2 //Number.isFinite数字是有尽的 3 console.log(Number.isFinite(15));//true 4 console.log(Number.isFinite(NaN));//false 5 console.log(Number.isFinite('true'/0));//false 6 console.log(Number.isNaN(NaN));//true 7 console.log(Number.isNaN(10));//false 8 } 9 { 10 //判断是否为整数,括号里面必须是数字 11 console.log('25',Number.isInteger(25));//true 12 console.log('25.0',Number.isInteger(25.0));//true 13 console.log('25.1',Number.isInteger(25.1));//false 14 console.log('25',Number.isInteger('25'));//false 15 } 16 { 17 //向下取整 18 console.log(4.1,Math.trunc(4.1));//4 19 console.log(4.9,Math.trunc(4.9));//4 20 } 21 { 22 //判断正数负数0,返回-1则为负数,0就是0,1为正数,NaN就是非数字 23 console.log('-5',Math.sign(-5));//-1 24 console.log('0',Math.sign(0));//0 25 console.log('5',Math.sign(5));//1 26 console.log('fff',Math.sign('fff'));//NaN 27 }