The _.max() function is used to find the minimum element from the list passed. If an iteratee is given, then it will be applied on each value and generate a criteria to rank the values and find the minimum element.
_.max(list, [iteratee], [context])
Parameters: This function accepts three parameters as mentioned above and described below:
- List: This parameter is used to hold the list of items.
- Predicate: This parameter is used to hold the test condition.
- Context: This parameter is used to display the content.
Return values: The return value is the element of the list which is maximum. A numbers list will give the maximum number and that of the string will give the string which is last when they are placed alphabetically.
Passing an array of numbers to the _.max function(): The ._max() function takes the element from the list one by one and do the compares the elements to find the maximum number in the list. After traversing and comparing all the elements, the _.max() function ends.
Passing a list of both numbers and strings as its property to _.max() function: Passing a list of both numbers and strings and compare the elements by one of the property. Either by the numbers property or by the string property. Like here we are comparing on the ‘difficulty’ property. The largest difficulty element will be returned.
Passing a structure of more than 1 property to the _.min() function: First, declare the array (here array is ‘arr’) and choose one property out of the many, on the basis of which need to find the maximum like here ‘hasLongHairs’. Console.log the variable in which this returned maximum value is stored.
Passing ‘true’ and ‘false’ as the elements of the list to the _.max() function: Passing the ‘true’ and ‘false’ values to the _.max() function. The maximum of these values will be defined as ‘true’ if it is present in the list at least once otherwise answer will be ‘false’. This is just the opposite if the ‘_.min()’ function.
- HTML | DOM Meter max Property
- HTML | DOM Input Range max Property
- PHP Math Functions (is_nan, pow, sqrt, exp, log, log10, log1p, max, min, getrandmax, rand, mt_rand)
- PHP | max( ) Function
- D3.js | d3.max() function
- CSS | max-height Property
- CSS | max-width Property
- HTML | DOM Progress max Property
- PHP program to Generate the random number in the given range (min, max)
- HTML | DOM Input Datetime max Property
- HTML | DOM Input Date max Property
- HTML | DOM Input DatetimeLocal max Property
- HTML | DOM Input Number max Property
- HTML | DOM Input Week max Property
- HTML | DOM Input Month max Property
- HTML | DOM Input Time max Property
- p5.js | max() function
- HTML | <input>max Attribute
- HTML | <meter> max Attribute