Why null is set as first parameter, when I put any number there like Math.max.apply(100, arr); it also works. What is the purpose of this first argument?
Your code so far
var arr = [6, 89, 3, 45];
var maximus = Math.max.apply(null, arr); // returns 89
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0.
Challenge: Use the Spread Operator to Evaluate Arrays In-Place
It isn’t super important to get into the weeds of using .apply() this way, because ES6 introduced a better way to do it (which is the real topic of this challenge).
That said…
Syntax
.apply(thisArg, [ argsArray])
Parameters
thisArg
The value of this provided for the call to func .
Note that this may not be the actual value seen by the method: if the method is a function in non-strict mode code, null and undefined will be replaced with the global object, and primitive values will be boxed. This argument is required.
argsArray Optional
An array-like object, specifying the arguments with which func should be called, or null or undefined if no arguments should be provided to the function.