使用 Math.min() 确定数组中最小的数
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 数组排序</h1>
- <p>最低值是:<span id="demo"></span></p>
- <script>
- var points = [40, 100, 1, 5, 25, 10];
- document.getElementById("demo").innerHTML = myArrayMin(points);
- function myArrayMin(arr) {
- return Math.min.apply(null, arr);
- }
- </script>
- </body>
- </html>