JavaScript 参考手册
JavaScript min() 方法
返回最小
源代码:
点击运行 »
<p id="demo">单击按钮比较数值大小并返回最小值。</p> <button onclick="myFunction()">点我</button> <script> function myFunction() { var a = Math.min(5, 10); var b = Math.min(0, 150, 30, 20, 38); var c = Math.min(-5, 10); var d = Math.min(-5, -10); var e = Math.min(1.5, 2.5); var x = document.getElementById("demo"); x.innerHTML = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e; } </script>
运行结果:
点击运行 »