Math对象的属性定义的函数和常量来实现:
Math.pow(2,53); //2的53次幂
Math.round(.6); //四舍五入
Math.ceil(.6); //向上求整
Math.floor(.6); //向下求整
Math.abs(-5); //绝对值
Math.max(x,y,z); //返回最大值
Math.min(x,y,z); // 返回最小值
Math.random(); //生成一个大于0小于1.0的伪随机数
Math.PI; //圆周率
Math.E; //自然对数的
Math.sqrt(3); //3的平方根
Math.pow(3,1/3); //3的立方根
Math.sin(0); //三角函数
Math.log(10); //10的自然对数
Math.log(100) / Math.LN10 ; //以10为底100的对数
Math.exp(3); //e的三次幂
网友评论