Math内置对象 常用的方法

  属性: Math.Pi 

  方法: Math.max()   最大值

      Math.min()  最小值

      Math.ceil()  向上取整

      Math.floor() 向下取整  

      Math.random()  取随机数

      Math.abs()    绝对值

      Math.pow()   幂

      Math.sqrt()  平方

 

重点  随机数的用法

function getRandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }

 

posted @ 2022-04-07 09:15  会前端的洋  阅读(54)  评论(0)    收藏  举报