JavaScript · Junior · Question 30 of 75
What does Math.max(...[3, 7, 2]) return?
- ✓Correct answer:
7 - 2
NaN - 3
[3, 7, 2]
Explanation
Spread "expands" the array into separate arguments: Math.max(3, 7, 2). Without spread, Math.max([3, 7, 2]) returns NaN. Spread is also used to copy and merge arrays and objects.