Math對象沒有構造函數,是一個固有的對象,這是它與Date,String對象的區別javascript
Math的相關函數所有爲靜態函數,應該直接調用java
Math.sin() -- 返回數字的正弦值
Math.cos() -- 返回數字的餘弦值
Math.tan() -- 返回數字的正切值
Math.asin() -- 返回數字的反正弦值
Math.acos() -- 返回數字的反餘弦值
Math.atan() -- 返回數字的反正切值
Math.atan2() -- 返回由x軸到點(x,y)的角度(以弧度爲單位)
Math.PI 屬性 -- 返回圓的周長與其直徑的比值(圓周率π),約等於3.1415926
Math.abs() -- 返回數字的絕對值
Math.ceil() -- 返回大於等於數字參數的最小整數(取整函數),對數字進行上舍入
Math.floor() -- 返回小於等於數字參數的最大整數,對數字進行下舍入
Math.round() -- 返回數字最接近的整數,四捨五入
Math.random() -- 返回0和1之間的僞隨機數
Math.max() -- 返回數個數字中較大的值
Math.min() -- 返回數個數字中較小的值
Math.max()dom
返回數個數值中較大的值函數
若是max函數沒有給出任何參數,返回-Infinityspa
若是有NaN或者非數字類型的參數,返回NaN對象
document.write(Math.max(5,8,6,-5,-6));//8
document.write(Math.max());//-Infinity
document.write(Math.max("dreamdu",8)); //NaN
document.write(Math.max(NaN,0)); //NaN
document.write(Math.max("-32","-9","-56","-878","-789","-767"));//-9
document.write(Math.max(-32,-9,-56,-878,-789,-767));//-9
document.write(Math.max("-32","-9",-56,"-878","-789",-767));//-9
document.write(Math.max(32,9,56,878,789,767));//878