Lodash _.lt() method checks if the value is less than the other value.
Syntax:
_.lt(value, other);Parameters:
- value: This parameter holds the first value that needs to be compared.
- other: This parameter holds the other value that is compared with.
Return Value:
This method returns true if the value is less than other else false.
Example 1: In this example, it is returning true as 34 is less than 67.
// Requiring the lodash library
const _ = require('lodash');
// Original array
let num = _.lt(34, 67);
// Using the _.lt() method
let less_elem = (num);
// Printing the output
console.log(less_elem);
Output:
trueExample 2: In this example, it is returning false as 77 is not less than 77.
// Requiring the lodash library
const _ = require('lodash');
// Original array
let num = _.lt(77, 77);
// Using the _.lt() method
let less_elem = (num);
// Printing the output
console.log(less_elem);
Output:
falseExample 3: In this example, it is returning false as 56 is not less than 36.
// Requiring the lodash library
const _ = require('lodash');
// Original array
let num = _.lt(56, 36);
// Using the _.lt() method
let less_elem = (num);
// Printing the output
console.log(less_elem);
Output:
falseNote: This code will not work in normal JavaScript because it requires the library lodash to be installed.