How to search the max value of an attribute in an array object ?
Maximum value of an attribute in an array of objects can be searched in two ways, one by traversing the array and the other method is by using the Math.max.apply() method.
Example 1: In this example, the array is traversed and the required values of the object are compared for each index of the array.
Example 2: In this example, we find the max value of an attribute by using Math.max.apply() function. It has two parameters:
- array-like object
Math.max.apply(thisArg, [ argsArray])
More information can be found at https://developer.mozilla.org/