原来Math.min和Math.max可以这么用。。
代码如下 |
复制代码 |
function smallest(array){
return Math.min.apply( Math, array );
}
function largest(array){
return Math.max.apply( Math, array );
}
alert(smallest([0, 1, 2, 3]) == 0, "Locate the smallest value.");
alert(largest([0, 1, 2, 3]) == 3, "Locate the largest value.");
|
Math对象调用Math对象的min方法?不太理解。
代码如下 |
复制代码 |
function smallest(){
return Math.min.apply( Math, arguments );
}
function largest(){
return Math.max.apply( Math, arguments );
}
alert(smallest(0, 1, 2, 3) == 0, "Locate the smallest value.");
alert(largest(0, 1, 2, 3) == 3, "Locate the largest value.");
|