1. 语法:Math.max(value1[,value2, ...])
    1. 使用:Math.max(),而不是创建的 Math 实例的方法(Math 不是构造函数)。
    2. 返回值
    3. 如果没有参数,则结果为 - Infinity。
    4. 如果有任一参数不能被转换为数值,则结果为 NaN。
    1. Math.PI //圆周率
    2. Math.floor() //向下取整
    3. Math.ceil() //向上取整
    4. Math.round() //四舍五入 就近取整 (注:-3.5 结果是-3)往大的取
    5. Math.abs() //绝对值
    6. Math.max()/Math.min() //最大值和最小值
    1. Math.roundom()
    2. 1、返回一个随机小数[0,1)
    3. 2、不跟参数
    4. 得到一个两数之间的随机数
    5. return Math.random() * (max - min) + min;
    6. 得到一个两数之间的随机整数
    7. function getRandomInt(min, max) {
    8. min = Math.ceil(min);
    9. max = Math.floor(max);
    10. return Math.floor(Math.random() * (max - min)) + min; //不含最大值,含最小值
    11. return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
    12. }
    1. <script>
    2. function getRandomInt(min, max) {
    3. min = Math.ceil(min);
    4. max = Math.floor(max);
    5. return Math.floor(Math.random() * (max - min+1)) + min; //不含最大值,含最小值
    6. }
    7. console.log(getRandomInt(1,10));
    8. var arr = ['d','a','i','w','w'];
    9. console.log(arr[getRandomInt(0,arr.length-1)]);
    10. </script>
    1. 播放量
    2. <script>
    3. function handleNum(num){
    4. if(num>=100000000){
    5. num = (num/10000000)+"亿"
    6. }
    7. else if(num>=10000){
    8. num = Math.ceil(num/10000)+"万"
    9. }
    10. return num+"";
    11. }
    12. var arr =[
    13. {name:"你好",playcount:4000},
    14. {name:"它",playcount:'404000'},
    15. {name:"我",playcount:200000000},
    16. ]
    17. arr.forEach(item=>{
    18. item.playcount = handleNum(item.playcount);
    19. })
    20. console.log(arr)
    21. </script>