D3.js maxIndex() Method Last Updated : 23 Sep, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report With the help of d3.maxIndex() method, we can get the index of value which is found to be maximum in an array of numbers, strings or dates. We can use any kind of array we just got the index of maximum value by using this method. Syntax: d3.maxIndex( iterable ) Parameter: This function has the following parameter as mentioned above and described below: iterable: Insert any kind of iterable object. Return Value: It will return the index of maximum value. Note: To execute the below examples, you have to install the d3 library by using this command prompt we have to execute the following command. npm install d3 Example 1: In this example, we can see that by using d3.maxIndex() method, we are able to find the index of a maximum value in an array of numbers, strings and date formatted by this method. Filename: index.js javascript // Defining d3 contrib variable var d3 = require('d3'); var arr = [] for(var i = 0; i < 5; i++) { arr.push(i); } var index = d3.maxIndex(arr) console.log(index) Output: 4 Example 2: Filename: index.js javascript // Defining d3 contrib variable var d3 = require('d3'); var index = d3.maxIndex([new Date(), new Date("2020-09-01"), new Date("2020")]) console.log(index) Output: 0 Note: The above program will compile and run by using the following command: node index.js Reference: https://github.com/d3/d3-array/blob/master/README.md Comment More infoAdvertise with us Next Article D3.js maxIndex() Method J jitender_1998 Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js greatestIndex() Method With the help of d3.greatestIndex() method, we can get the index of the largest value from the sequence of numbers in an array by using this method. Syntax: d3.greatestIndex( iterable, accessor ) Return value: It returns the index of the largest value. Note: To execute the below examples you have to 1 min read Lodash _.max() Method Lodash _.max() method is used to find the maximum element from the array. If the array is empty then undefined is returned.Syntax:_.max( array );Parameters:array: It is the array that the method iterates over to get the maximum element.Return Value: This method returns the maximum element from the a 2 min read Collect.js max() Method The max() method is used to return the maximum value of a given key. It takes a collection and returns the maximum values present in that collection for a given key. Syntax: collect(array).max(key)Parameters: The collect() method takes one argument that is converted into the collection and then the 2 min read Lodash _.maxBy() Method Lodash _.maxBy() method is used to compute the maximum value from the original array by iterating over each element in the array using the Iteratee function. It is almost the same as the _.max() function.Syntax:_.maxBy( array, [iteratee = _.identity] );Parameters: array: It is the array that the met 3 min read D3.js greatest() Method With the help of d3.greatest() method, we can get the largest value from the sequence of numbers in an array by using this method. Syntax: d3.greatest(iterable) Parameter: This function has the following parameter as mentioned above and described below: iterable: Insert any kind of iterable object. 1 min read Like