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:
- value: This parameter holds the first value that is used to compare.
- other: This parameter holds the other value that compares with the other value.
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.
javascript
// 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.
javascript
// 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.
javascript
// 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.
Contact Us