zoukankan      html  css  js  c++  java
  • JavascriptBoolean/Math

    Boolean描述:

    创建新的 Boolean 值

    var boolObj = new Boolean([boolValue])

    如果忽略 Boolvalue ,或者其值为 false、0、nullNaN,或者空字符串,则该 Boolean 对象的初始值为 false。否则,初始值为 true

    Boolean方法:

    方法 描述 备注
    toString() 将逻辑值转化为字符串,并返回  
    valueOf() 返回boolean值的原始值  

    Math描述:

    提供基本数学函数和常数

    Math属性:

    属性 描述 备注
    E 常量 e,自然对数的底数 约等于2.718
    LN2 返回 2 的自然对数 约等于0.693
    LN10 返回 10 的自然对数 约等于2.302
    LOG2E 返回以 2 为底的 e 的对数 约等于 1.414
    LOG10E 返回以 10 为底的 e 的对数 约等于0.434
    PI 返回圆周率 约等于3.14159
    SQRT1_2 返回 2 的平方根分之一 约等于 0.707
    SQRT2 返回 2 的平方根 约等于 1.414

    Math方法:

    方法 描述 备注
    abs(x) 返回数的绝对值  
    sin(x) 返回数(弧度)的正弦值  
    cos(x) 返回数(弧度)的余弦值  
    asin(x) 返回数的反正弦值  
    acos(x) 返回数的反余弦值  
    tan(x) 返回数(弧度)的正切值  
    atan(x) 以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值  
    atan(x,y) 返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间)  
    max(x,y) 返回x,y中最大的数字  
    min(x,y) 返回x,y中最小的数字  
    pow(x,y) 返回x的y次幂  
    sqrt(x) 返回数的平方根  
    ceil(x) 对一个数进行向上舍入,返回一个整数  
    floor(x) 对一个数进行向下舍入,返回一个整数  
    round(x) 把一个数四舍五入为最近的整数  
    exp(x) 返回e的指数  
    log(x) 返回数的自然对数(底数为e)  
    random() 返回0--1之间的随机数  

    Math例子:

        <script type="text/javascript">
            document.write("<br/>Math.abs(-1):"+Math.abs(-1));
            document.write("<br/>Math.sin(Math.PI/6):"+Math.sin(Math.PI/6));
            document.write("<br/>Math.cos(Math.PI/3):"+Math.cos(Math.PI/3));
            document.write("<br/>Math.asin(0.5)*180/Math.PI:"+Math.asin(0.5)*180/Math.PI);
            document.write("<br/>Math.acos(0.5)*180/Math.PI:"+Math.acos(0.5)*180/Math.PI);
            document.write("<br/>Math.tan(Math.PI/3):"+Math.tan(45*Math.PI/180));
            document.write("<br/>Math.atan(1)*180/Math.PI:"+Math.atan(1)*180/Math.PI);
            document.write("<br/>Math.max(9,10):"+Math.max(9,10));
            document.write("<br/>Math.min(9,10):"+Math.min(9,10));
            document.write("<br/>Math.pow(2,3):"+Math.pow(2,3));
            document.write("<br/>Math.sqrt(9):"+Math.sqrt(9));
            document.write("<br/>Math.ceil(9.1):"+Math.ceil(9.1));
            document.write("<br/>Math.floor(9.1):"+Math.floor(9.1));
            document.write("<br/>Math.round(9.31):"+Math.round(9.31));
            document.write("<br/>Math.round(9.7):"+Math.round(9.7));
            document.write("<br/>Math.exp(2):"+Math.exp(1));
            document.write("<br/>Math.log(2):"+Math.log(1));        
            document.write("<br/>Math.random:"+Math.random());
        </script>
    结果:
    image 
  • 相关阅读:
    不要对父母说的十句话
    25句世界上最經典的話
    奥巴马(Obama)获胜演讲全文[中英对照]+高清视频下载
    【心理测试】男人眼中女人哪里最性感?
    一张图看出你是用左脑还是右脑
    我是有原则的~~(笑话转贴)
    各行各业常用大用大谎言
    你知道我今天为啥要来上班吗?
    女性抽烟腰会变粗?
    心理学家揭秘人临死时的感受
  • 原文地址:https://www.cnblogs.com/oneword/p/1493383.html
Copyright © 2011-2022 走看看