W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!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) { var len = arr.length; var min = Infinity; while (len--) { if (arr[len] < min) { min = arr[len]; } } return min; } </script> </body> </html>