Lodash _.min() method is used to find the minimum element from the array. If the array is empty then undefined is returned.
Syntax:
_.min(array);
Parameters:
- array: It is the array that the method iterates over to get the minimum element.
Return Value:
This method returns the minimum element from the array.
Example 1: In this example, we are getting the undefined value as the given array is empty so the lodash _min() method returns the undefined value.
Javascript
const _ = require("lodash");
let min_val = _.min([]);
console.log(min_val);
|
Output:
undefined
Example 2: In this example, we are getting the minimum value of the given array by the use of the lodash _min() method.
Javascript
const _ = require("lodash");
let min_val = _.min([15, 7, 38, 46, 82]);
console.log(min_val);
|
Output:
7
Example 3: In this example, we are getting the minimum value of the given array by the use of the lodash _min() method.
Javascript
const _ = require("lodash");
let min_val = _.min([-15, 7, 38, -46, -82]);
console.log(min_val);
|
Output:
-82
Learn to code easily with our course
Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks 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!
Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated :
30 Oct, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...