Lodash _.lt() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, collection, strings, lang, function, objects, numbers etc.

The _.lt() method checks if value is less than the other value.

Syntax:

_.lt(value, other)

Parameters: This method accepts two parameters as mentioned above and described below:

  • value: This parameter holds the first value that need to compare.
  • other: This parameter holds the other value that is compare with.

Return Value: This method returns true if value is less than other else false.



Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.

filter_none

edit
close

play_arrow

link
brightness_4
code

// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var num = _.lt(34, 67);
  
// Using the _.lt() method
let less_elem = ( num );
  
// Printing the output 
console.log(less_elem);

chevron_right


Output:

true

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var num = _.lt(77, 77);
  
// Using the _.lt() method
let less_elem = ( num );
  
// Printing the output 
console.log(less_elem);

chevron_right


Output:

false

Example 3:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var num = _.lt(56, 36);
  
// Using the _.lt() method
let less_elem = ( num );
  
// Printing the output 
console.log(less_elem);

chevron_right


Output:

false

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.

full-stack-img




My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.