MDN的网址
Math:
Math数学对象 不是一个构造函数,所以我们不需要new 来调用 而是直接使用里面的属性和方法即可
///console.log(Math.PI); //一个属性 圆周率 console.log(Math.max(1,99,10)); // 99 console.log(Math.max(-1,-20)); //-1 console.log(Math.max(1,10,'你好')); // NaN console.log(Math.max());//-Infinty
///
案例
// 利用对象封装自己的数学对象 里面有PI 最大值 最小值 var myMath = { PI: 3.141592653, max: function () { var max = arguments[0]; for (var i = 1; i < arguments.length; i++) { if (arguments[i] > max) { max = arguments[i]; } } return max; }, min: function () { var min = arguments[0]; for (var i = 1; i < arguments.length; i++) { if (arguments[i] < min) { min = arguments[i]; } } return min; } } console.log(myMath.PI); //3.141592653 console.log(myMath.max(1,4,5)); //5 console.log(myMath.min(3,4,6)); //3