js--Math round() random()

2019-03-09  本文已影响0人  hsqin

Math方法整理

常用方法: random max min round floor
常见属性: PI

Math参考地址--w3school

console.log('Math.round-------↓↓↓↓↓↓')
console.log('-2.2 round之后是 ',Math.round(-2.2)); // -2
console.log('-2.8 round之后是 ',Math.round(-2.8)); // -3
console.log('-3.5 round之后是 ',Math.round(-3.5)); // -3,这里要注意!!!!!
console.log('3.5 round之后是 ',Math.round(-3.5)); // 4
round注意负数.png
//Math.random()*10+1 -- 返回1(包含)到10(包含)之间的随机数
Math.random() = 0.30452571289742103

Math.floor(number) --- 返回≤number的最近的那个整数
Math.ceil(number) ---返回≥number的最近的那个整数
ceil --- vt.装天花板
floor --- n.地板,地面

Math.pow(4,3) == 4*4*4 = 64
Math.sqrt(9) = 3
Math.sqrt(-1) = NaN
上一篇 下一篇

猜你喜欢

热点阅读