JS中的内置对象Math的使用

 


//Math.max和Math.min的用法 var arr = [10, 20, 30, 48, 99, 101, 200]; var a = Math.max.apply(null, arr) document.write(a); //Math.min var arr = [10, 20, 30, 48, 99, 101, 200]; var a = Math.min.apply(null, arr) document.write(a);
    //Math.abs的用法
document.write(Math.abs(-10)+"<br>");
document.write(Math.abs(-0.1)+"<br>");
document.write(Math.abs(10)+"<br>");
document.write(Math.abs("string")+"<br>");
document.write(Math.abs());
//结果
10
0.1
10
NaN
NaN

 

posted @ 2019-03-18 17:03  showTimehzy  阅读(261)  评论(0编辑  收藏  举报