Re:Fast JavaScript Max/Min
by jashkenas on Monday March 28, 2011 @07:33AM
(#2377961)
The real reason why Underscore doesn't use "Math.max.apply" and "Math.min.apply", is that they only work on small arrays of numbers. After you get beyond 40-50,000-ish (last time I checked), some browsers will throw an exception because you can't pass that many arguments to a function.
I remember running into this in real-world code, trying to calculate the brightest pixel in a <canvas> imageData array.
I remember running into this in real-world code, trying to calculate the brightest pixel in a <canvas> imageData array.