原生JS—Math对象

var num1=0.45;


console.log(Math.ceil(num1)); //1 ceil是Math对象向上取整的方法
console.log(Math.floor(num1)); //0 floor是Math对象向下取整的方法
console.log(Math.round(num1)); //0 round是Math对象四舍五入的方法
console.log(Math.random());        //random是Math对象取随机数(0> and <1)的方法


++n 和n++ 的区别

var n1=123;
  var n2=n1++;  //先将n1赋值给n2,之后n1再自增

alert(n2);
  alert(n1);

var  n3=123;
  var  n4=++n3;  //n1先自增,在赋值给n2
  alert(n4);
  alert(n3);


原文地址:https://www.cnblogs.com/vzaiBoke/p/8764939.html