// 获取数组中的最大值
// 使用 Math.max() 和 spread 运算符
const numbers = [1, 5, 2, 8, 3];
const maxNumber = Math.max(...numbers);
console.log(maxNumber); // 输出: 8
// 解释说明:
// Math.max() 是 JavaScript 中用于获取最大值的内置函数。
// 它接受多个参数并返回这些参数中的最大值。
// 使用 spread 运算符 (...) 可以将数组元素展开为独立的参数传递给 Math.max()。
上一篇:js 获取焦点
下一篇:js 获取元素内容
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站