<!--js中的Math.max()和Math.min()方法只接受可变长度的参数列表,不接受直接传递数组的形式,可以用apply的方法改变传参的方式-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#results li.pass{color:green;}
#results li.fail{color:red;}
</style>
</head>
<body>
<ul id="results"></ul>
<input id="first"/>
<input id="second"/>
<script>
function smallest(array){
return Math.min.apply(Math,array);
}
function biggest(array){
return Math.max.apply(Math,array);
}
</script>
</body>
</html>
更改Math.max()和Math.min()的传参方式
最新推荐文章于 2024-08-02 21:53:36 发布