Lodash JavaScript Utility Library Documentation

repository·main·Indexed Apr 15, 2026

https://github.com/lodash/lodash

Lodash is a modular JavaScript utility library offering methods for arrays, numbers, objects, and strings. Features include implicit and explicit chaining via _() and _.chain(), shortcut fusion for lazy evaluation, and wrapper methods like _.tap and _.thru. Supports Node.js (require, lodash-es), browser (script tags), and modular installs (lodash/core, lodash/fp, per-method packages). Includes methods like _.differenceWith for custom comparators.

Tokens
70.7K
Snippets
385
Records
529
Agent score
100%

What's inside lodash

  1. Drop elements from the end of an array with `_.dropRight`

    main

    Creates a slice of the array with n elements dropped from the end.

    Usage:

    _.dropRight([1, 2, 3]);
    // => [1, 2]
    
    _.dropRight([1, 2, 3], 2);
    // => [1]
    
    _.dropRight([1, 2, 3], 5);
    // => []
    
    _.dropRight([1, 2, 3], 0);
    // => [1, 2, 3]

    Parameters:

    • array (Array): The array to query.
    • n (number): The number of elements to drop. Defaults to 1.

    Note: The n argument can be used as an iteratee for methods like _.map.

    Sources: lodash.js

  2. Use _.isFinite to check for finite numbers

    main

    Checks if a value is a finite primitive number. Based on Number.isFinite.

    Usage:

    _.isFinite(3);
    // => true
    
    _.isFinite(Infinity);
    // => false
    
    _.isFinite('3');
    // => false

    Sources: doc/README.md

  3. Use _.gt and _.gte for numeric comparisons

    main

    Use _.gt(value, other) to check if value is greater than other, and _.gte(value, other) to check if value is greater than or equal to other.

    Usage:

    _.gt(3, 1);  // => true
    _.gt(3, 3);  // => false
    _.gt(1, 3);  // => false
    
    _.gte(3, 1); // => true
    _.gte(3, 3); // => true
    _.gte(1, 3); // => false

    Import:

    import gt from 'lodash/gt';
    import gte from 'lodash/gte';

    Sources: doc/README.md

  4. Get the last element of an array with _.last

    main

    Gets the last element of array. Returns undefined if the array is empty.

    Usage:

    _.last([1, 2, 3]);
    // => 3

    Sources: lodash.js

  5. Use _.at to extract values by property paths

    main

    Use _.at to create an array of values corresponding to specific property paths in an object. You can pass paths as individual strings or an array of strings.

    Usage:

    var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
    
    _.at(object, ['a[0].b.c', 'a[1]']);
    // => [3, 4]

    Arguments:

    • object (Object): The object to iterate over.
    • [paths] (...(string|string[])): The property paths to pick.

    Sources: doc/README.md

  6. Use _.isArrayBuffer to check for ArrayBuffer instances

    main

    Use _.isArrayBuffer(value) to check if a value is classified as an ArrayBuffer object.

    Usage:

    _.isArrayBuffer(new ArrayBuffer(2)); // => true
    _.isArrayBuffer(new Array(2)); // => false

    Import:

    import isArrayBuffer from 'lodash/isArrayBuffer';

    Sources: doc/README.md

  7. Split arrays into chunks with `_.chunk`

    main

    Splits an array into groups of a specified size. If the array cannot be split evenly, the final chunk contains the remaining elements.

    Usage:

    _.chunk(['a', 'b', 'c', 'd'], 2);
    // => [['a', 'b'], ['c', 'd']]
    
    _.chunk(['a', 'b', 'c', 'd'], 3);
    // => [['a', 'b', 'c'], ['d']]

    Parameters:

    • array (Array): The array to process.
    • size (number): The length of each chunk. Defaults to 1.

    Note: The size argument can be used as an iteratee for methods like _.map.

    Sources: lodash.js