However, if you want to get the maximum of a number in an array, you want to pass the numbers that are in the array to the max function, not the array itself. That’s where the apply function comes in to play.
apply() is a function that every function in javascript has. In this case, here’s what’s happening:
The apply() function takes two arguments: the first is the this argument: that is, the value that will be passed to the function as this. The second argument that apply() takes is an array of arguments to pass to the function that we’re calling, in this case Math.max.
I don’t know how well I’ve explained this, so if you’re looking for more information, take a look at the MDN page for apply().