or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash-lt

Checks if value is less than other using JavaScript's native comparison operator

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.lt@3.9.x

To install, run

npx @tessl/cli install tessl/npm-lodash-lt@3.9.0

index.mddocs/

Lodash.lt

Lodash.lt provides a simple utility function for performing less-than comparison operations. This function is part of the Lodash library's Lang category and offers a functional programming approach to comparison operations, allowing for consistent API usage and potential composition with other Lodash utilities.

Package Information

  • Package Name: lodash.lt (part of lodash library)
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash (full library) or npm install lodash.lt (individual function)

Core Imports

From full lodash library:

const _ = require('lodash');

ES6 imports (if using a module system):

import _ from 'lodash';

From individual lodash.lt package:

const lt = require('lodash.lt');

For direct access from full library:

const _ = require('lodash');
const lt = _.lt;

Basic Usage

Using full lodash library:

const _ = require('lodash');

// Compare numbers
console.log(_.lt(1, 3)); // => true
console.log(_.lt(3, 3)); // => false
console.log(_.lt(3, 1)); // => false

// Compare strings
console.log(_.lt('abc', 'def')); // => true
console.log(_.lt('def', 'abc')); // => false

Using individual lodash.lt package:

const lt = require('lodash.lt');

// Compare numbers
console.log(lt(1, 3)); // => true
console.log(lt(3, 3)); // => false
console.log(lt(3, 1)); // => false

// Compare mixed types (uses JavaScript's native < operator behavior)
console.log(lt(1, '2')); // => true
console.log(lt('10', 5)); // => false

Capabilities

Less Than Comparison

Checks if the first value is less than the second value using JavaScript's native less-than operator.

/**
 * Checks if `value` is less than `other`.
 *
 * @static
 * @memberOf _
 * @category Lang
 * @param {*} value The value to compare.
 * @param {*} other The other value to compare.
 * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`.
 */
function lt(value, other);

Parameters:

  • value (*): The value to compare - can be any JavaScript value
  • other (*): The other value to compare - can be any JavaScript value

Returns:

  • boolean: Returns true if value is less than other, else false

Behavior:

  • Uses JavaScript's native < operator for comparison
  • Follows JavaScript's type coercion rules when comparing different types
  • Works with numbers, strings, and other comparable JavaScript values
  • Part of Lodash's functional programming approach to utility operations

Usage Examples:

const _ = require('lodash');

// Numeric comparisons
_.lt(1, 3);     // => true
_.lt(3, 3);     // => false  
_.lt(3, 1);     // => false

// String comparisons (lexicographic)
_.lt('abc', 'def');  // => true
_.lt('def', 'abc');  // => false
_.lt('abc', 'abc');  // => false

// Mixed type comparisons (follows JavaScript < operator rules)
_.lt(1, '2');    // => true (1 < 2)
_.lt('10', 5);   // => false ('10' converted to 10, 10 < 5 is false)

// Can be used in functional programming contexts
const numbers = [3, 1, 4, 1, 5];
const lessThanThree = numbers.filter(n => _.lt(n, 3));
console.log(lessThanThree); // => [1, 1]

// Useful for sorting predicates or custom comparison logic
const compareWithTwo = (value) => _.lt(value, 2);
console.log(compareWithTwo(1)); // => true
console.log(compareWithTwo(3)); // => false