Thursday, December 11, 2025
HomeLanguagesJavascriptD3.js least() Method

D3.js least() Method

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

Syntax:

d3.least(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 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.least() method, we are able to get the 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.least([5, 4, 3, 2, 1])
  
console.log(gfg)


Output:

1

Example 2: Filename: index.js




// Defining d3 contrib variable  
var d3 = require('d3');
  
var arr = []
for(var i = 0; i < 5; i++) {
    arr.push(Math.random());
}
  
var gfg = d3.least(arr);
  
console.log(gfg);


Output:

0.09124116961036877

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32440 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6811 POSTS0 COMMENTS
Nicole Veronica
11950 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12023 POSTS0 COMMENTS
Shaida Kate Naidoo
6943 POSTS0 COMMENTS
Ted Musemwa
7193 POSTS0 COMMENTS
Thapelo Manthata
6889 POSTS0 COMMENTS
Umr Jansen
6880 POSTS0 COMMENTS