Open In App

Lodash _.lte() Method

Lodash _.lte() method checks if the value is less than or equal to the other value or not.

Syntax:

_.lte(value, other);

Parameters:

Return Value:

This method returns true if the value is less than or equal to other else false.



Example 1: In this example, it is returning true as both of the given values are equal.




// Requiring the lodash library
const _ = require('lodash');
 
// Original array
let num = _.lte(16, 16);
 
// Using the _.lte() method
let less_eq_elem = (num);
 
// Printing the output
console.log(less_eq_elem);

Output:



true

Example 2: In this example, it is returning true as 34 is less than 76.




// Requiring the lodash library
const _ = require('lodash');
 
// Original array
let num = _.lte(34, 76);
 
// Using the _.lte() method
let less_eq_elem = (num);
 
// Printing the output
console.log(less_eq_elem);

Output:

true

Example 3: In this example, it is returning false becuase 81 is not less than 46.




// Requiring the lodash library
const _ = require('lodash');
 
// Original array
let num = _.lte(81, 46);
 
// Using the _.lte() method
let less_eq_elem = (num);
 
// Printing the output
console.log(less_eq_elem);

Output:

false

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


Article Tags :