The Spread operator usually passes the array elements as an argument in the function. You can see the code example below:
const numbers = [1, 5, 4, 10, 9]; const maxValue = Math.max(...numbers); console.log(maxValue); // Output: 10
In the above code, we have a constant variable “numbers” in which the array containing numbers [1, 5, 4, 10, 9] is placed.
In the next step, we have declared a constant variable “maxValue” in which we have used the Math.max(…numbers) function this function will return the max value present in the array of numbers.
In the last step, the value of the constant variable “maxValue” is displayed in the console.