Why would you pass null to apply or call?
If there is no value that you want to indicate for the this pointer inside the function, and the function you are calling does not expect a specific this value for proper operation.
Would not explicitly pass the this keyword? Or at least more human readable. And again at this point, I may not understand why you should use null.
In your particular case, it is probably best to pass a Math object:
function getMax(arr){ return Math.max.apply(Math, arr); }
While it turns out that it doesn't matter what you pass as the first argument to Math.max.apply(...) (just because of the specifics of the implementation of Math.max() ), passing Math sets the this pointer to exact the same thing that would be set when you usually call it as Math.max(1,2,3) , so this is the safest option, since you best simulate a normal call to Math.max() .
Why would you pass null to apply or call?
Here are some more details ... When using .call() or .apply() , null can be passed when you do not have a specific value that you want to set for the this pointer, and you know that the function you are calling does not expect that this has any specific meaning (for example, it does not use this in its implementation).
Note. Using null with .apply() or .call() usually only .call() with functions that are methods only for namespaces, and not object-oriented. In other words, the max() function is a method of the Math object only for reasons related to names, and not because the Math object has instance data that the .max() method must access.
If you did it like this:
function foo() { this.multiplier = 1; } foo.prototype.setMultiplier = function(val) { this.multiplier = val; } foo.prototype.weightNumbers = function() { var sum = 0; for (var i = 0; i < arguments.length; i++) { sum += (arguments[i] * this.multiplier); } return sum / arguments.length; } var x = new foo(); x.setMultiplier(3); var numbers = [1, 2, 3] console.log(x.weightNumbers.apply(x, numbers));
When the method you call .apply() on needs to access the instance data, then you MUST pass the appropriate object as the first argument so that the method has the correct this pointer to do its work, as expected.