This was done to death to a large extent, here on SO and around the Web. However, I was wondering if the standard min / max functions could be used:
Array.max = function(array) { return Math.max.apply(Math, array); }; Array.min = function(array) { return Math.min.apply(Math, array); };
So, I can do a search on an array of objects:
function Vector(x, y, z) { this.x = x; this.y = y; this.z = z; } var ArrayVector = [ ]; var min_x = ArrayVector.x.min();
Currently, I have to go through the array and compare the values โโof the objects manually and process each of them with the specific need of the loop. A more general way would be nice (if a little slower).
javascript
graham.reeds
source share