• Math内置对象


    1,圆周率

      Math.PI

    2,最大值

      Math.max()

    3,最小值

      Math.min()

    4,  取整

    1,  向上取整,取最大

      Math.ceil()

    2,   向上取整,取最小

      Math.floor()

    3,   四舍五入

      Math.round

    5, 随机数,返回一个0-1之间的数

      Math.random() 

    ----------------------------------------------------------------------

    随机生成一个rgb

    rgb(0,0,0)每一项取值范围0-255

    var r = parseInt(Math.random()*256)

    var g = parseInt(Math.random()*256)

    var b = parseInt(Math.random()*256)

    var str = 'rgb(' + r +',' + g + ',' + b +')'

    setInterval (() {

      document.body.style.backgroundColor = str;

    },1000)

  • 相关阅读:
    Investment
    The Fewest Coins
    Bone Collector II
    Cow Exhibition
    饭卡
    A + B Problem II
    F
    敌兵布阵
    单例模式
    面向对象
  • 原文地址:https://www.cnblogs.com/xiaoxiao95/p/12906176.html
Copyright © 2020-2023  润新知