Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

D3.js leastIndex() Method

  • Last Updated : 23 Sep, 2020

With the help of d3.leastIndex() method, we can get the index of least value from the sequence of numbers in an array by using this method.

Syntax:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

d3.leastIndex( iterable )

Parameter: This function has the following parameter as mentioned above and described below:

  • iterable: Insert any kind of iterable object.



Return Value: It return the index of least 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.leastIndex() method, we are able to get the index of least value from the sequence from an array by using this method.

Filename: index.js




// Defining d3 variable  
var d3 = require('d3');
  
var gfg = d3.leastIndex([42, 12, 34, 21])
  
console.log(gfg)

Output:

1

Example 2: Filename: index.js




// Defining d3 variable  
var d3 = require('d3');
  
var arr = []
for(var i = 0; i < 5; i++) {
    arr.push(i * 2);
}
  
var gfg = d3.leastIndex(arr)
  
console.log(gfg)

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :