Why can't I write [1,2,3].reduce(Math.max) in Javascript?

Viewed 4386

Possible Duplicate:
How to use Math.max, etc. as higher-order functions

Using Mozilla's Javascript 1.6 array 'extension' functions (map, reduce, filter etc.), why is it that the following works as expected:

var max = [1,2,3].reduce(function(a,b) { return Math.max(a,b); });

But the following does not work (it produces NaN):

var max2 = [1,2,3].reduce(Math.max);

Is it because Math.max is a variadic function?

1 Answers
Related