企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 求数组中的最小值 ~~~ var array = [5, 7, 2, 3, 4, 1, 7, 9, 6]; ~~~ ## 循环遍历数组元素 ~~~ var min = array[0], index = 0; for (var i = 1; i < array.length; i++) { if (min > array[i]) { min = array[i]; index = i; } } ~~~ ## Apply ~~~ var min = Math.min.apply(null, array); console.log(min) ~~~ ## Math求值 ~~~ var [a, b, ...c] = array; console.log(a, b, c) var min = Math.min(...array); console.log(min) ~~~