🔥 配列クロムから最大数を得る:数学上の“最大呼び出しスタックサイズを超えた”エラーを解決する方法.max . apply ( math , array )


Math.max()は、それに渡された0以上の数の最大値を返します.この配列から最大数を得るには、配列を渡すときに、スプレッド演算子を使用できます.
// get the largest number from a list of numbers
Math.max(69, 420, 108, 47)  // ⇒ 420

// passing an array instead of individual numbers returns `NaN`
const numbers = [69, 420, 108, 47]
Math.max(numbers)           // ⇒ NaN

// we get the expected result by spreading the array
const numbers = [69, 420, 108, 47]
Math.max(...numbers)        // ⇒ 420