zoukankan      html  css  js  c++  java
  • JS基础语法----Math对象

        推荐查看MDN----在线的帮助文档

    1.     实例对象: 通过构造函数创建出来,实例化的对象
    2.     静态对象: 不需要创建,直接就是一个对象,方法(静态方法)直接通过这个对象名字调用
    3.     实例方法必须通过实例对象调用
    4.     静态方法必须通过大写的对象调用
     
        Math.PI----π
        Math.E----常数的底数
        Math.abs(值)-----绝对值
        Math.ceil(值)----向上取整
        Math.floor(值)---向下取整
     
       console.log(Math.PI);
       console.log(Math.E);
       console.log( Math.abs('-1'));//1
    
       console.log( Math.abs(-2));//2
       console.log(Math.abs(null));//---------0  重点
       console.log(Math.abs("string"));//NaN
       console.log(Math.ceil(12.3));
       console.log(Math.ceil(12.9));
       console.log(Math.ceil(12.09));
       console.log(Math.ceil(12.03));
       console.log(Math.ceil(12.92));
       console.log(Math.floor(12.3));
       console.log(Math.floor(12.9));
       console.log(Math.floor(12.09));
       console.log(Math.floor(12.03));
       console.log(Math.floor(12.92));
       console.log(Math.fround(2));
       console.log(Math.fround(2.1));
       console.log(Math.fround(2.9));
        //找一坨数字中的最大值
       console.log(Math.max(10,1,9,100,200,45,78));
       console.log(Math.min(10,1,9,100,200,45,78));
       
       console.log(Math.pow(2,4));
       console.log(Math.sqrt(16));
        console.log(parseInt(Math.random()*5)+1);
        console.log(parseInt(Math.random()*100)+1);
  • 相关阅读:
    第四章作业
    第二章上机实验报告
    对二分法的理解和结对编程情况
    Mysql与sql server的列的合并
    C#中如何去除窗体默认的关闭按钮
    C# 实现WinForm窗口最小化到系统托盘代码,并且判断左右鼠标的事件
    running total sql 2012+
    Poqwe Pivot error
    事务
    ssis 导EXCEL ERROR
  • 原文地址:https://www.cnblogs.com/jane-panyiyun/p/11972666.html
Copyright © 2011-2022 走看看