js 的一些操作

  var p= 10
  //保留两位小数点
  console.log(Math.round(p * 10000) /100)

   //js 随机数Math
   //1、0-x之间的随机数:
 Math.round(Math.random()*x);

  //2、x至y之间的随机数
  Math.round(Math.random()*(y-x)+x);

  //3、1-x之间的随机数:
  Math.ceil(Math.random()*x);

 

posted @ 2017-08-16 16:51  no_xlove  阅读(88)  评论(0)    收藏  举报