Functions

Browse all available utility functions by category

arrays

chunk

Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

Example:

chunk(['a', 'b', 'c', 'd'], 2); // [['a', 'b'], ['c', 'd']]
arrays

compact

Creates an array with all falsy values removed. The values false, null, 0, "", undefined, and NaN are falsy.

Example:

compact([0, 1, false, 2, '', 3]); // [1, 2, 3]
arrays

concat

Creates a new array concatenating array with any additional arrays and/or values.

Example:

const array = [1];
arrays

difference

Creates an array of array values not included in the other given arrays. The order and references of result values are determined by the first array.

Example:

difference([2, 1], [2, 3]); // [1]
arrays

differenceBy

This method is like difference except that it accepts iteratee which is invoked for each element of array and values to generate the criterion by which they're compared.

Example:

differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [1.2]
arrays

differenceWith

This method is like difference except that it accepts comparator which is invoked to compare elements of array to values.

Example:

const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
arrays

drop

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

Example:

drop([1, 2, 3]); // [2, 3]
arrays

dropRight

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

Example:

dropRight([1, 2, 3]); // [1, 2]
arrays

dropRightWhile

Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate returns falsey.

Example:

const users = [
arrays

dropWhile

Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey.

Example:

const users = [
arrays

fill

Fills elements of array with value from start up to, but not including, end.

Example:

const array = [1, 2, 3];
arrays

findIndex

Returns the index of the first element predicate returns truthy for instead of the element itself.

Example:

const users = [
arrays

findLastIndex

This method is like findIndex except that it iterates over elements of collection from right to left.

Example:

const users = [
arrays

first

Gets the first element of array.

Example:

first([1, 2, 3]); // 1
arrays

flatten

Flattens array a single level deep.

Example:

flatten([1, [2, [3, [4]], 5]]); // [1, 2, [3, [4]], 5]
arrays

flattenDeep

Recursively flattens array.

Example:

flattenDeep([1, [2, [3, [4]], 5]]); // [1, 2, 3, 4, 5]
arrays

flattenDepth

Recursively flatten array up to depth times.

Example:

const array = [1, [2, [3, [4]], 5]];
arrays

fromPairs

Returns an object composed from key-value pairs.

Example:

fromPairs([['a', 1], ['b', 2]]); // { 'a': 1, 'b': 2 }
arrays

head

Gets the first element of array.

Example:

head([1, 2, 3]); // 1
arrays

indexOf

Gets the index at which the first occurrence of value is found in array.

Example:

indexOf([1, 2, 1, 2], 2); // 1
arrays

initial

Gets all but the last element of array.

Example:

initial([1, 2, 3]); // [1, 2]
arrays

intersection

Creates an array of unique values that are included in all given arrays.

Example:

intersection([2, 1], [2, 3]); // [2]
arrays

intersectionBy

This method is like intersection except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which they're compared.

Example:

intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1]
arrays

intersectionWith

This method is like intersection except that it accepts comparator which is invoked to compare elements of arrays.

Example:

const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
arrays

join

Converts all elements in array into a string separated by separator.

Example:

join(['a', 'b', 'c'], '~'); // 'a~b~c'
arrays

last

Gets the last element of array.

Example:

last([1, 2, 3]); // 3
arrays

lastIndexOf

This method is like indexOf except that it iterates over elements of array from right to left.

Example:

lastIndexOf([1, 2, 1, 2], 2); // 3
arrays

nth

Gets the element at index n of array. If n is negative, the nth element from the end is returned.

Example:

const array = ['a', 'b', 'c', 'd'];
arrays

pull

Removes all given values from array.

Example:

const array = ['a', 'b', 'c', 'a', 'b', 'c'];
arrays

pullAll

This method is like pull except that it accepts an array of values to remove.

Example:

const array = ['a', 'b', 'c', 'a', 'b', 'c'];
arrays

pullAllBy

This method is like pullAll except that it accepts iteratee which is invoked for each element of array and values to generate the criterion by which they're compared.

Example:

const array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
arrays

pullAllWith

This method is like pullAll except that it accepts comparator which is invoked to compare elements of array to values.

Example:

const array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
arrays

pullAt

Removes elements from array corresponding to indexes and returns an array of removed elements.

Example:

const array = ['a', 'b', 'c', 'd'];
arrays

remove

Removes all elements from array that predicate returns truthy for and returns an array of the removed elements.

Example:

const array = [1, 2, 3, 4];
arrays

reverse

Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.

Example:

const array = [1, 2, 3];
arrays

slice

Creates a slice of array from start up to, but not including, end.

Example:

const array = [1, 2, 3, 4];
arrays

sortedIndex

Uses a binary search to determine the lowest index at which value should be inserted into array in order to maintain its sort order.

Example:

sortedIndex([30, 50], 40); // 1
arrays

sortedIndexBy

This method is like sortedIndex except that it accepts iteratee which is invoked for value and each element of array to compute their sort ranking.

Example:

const objects = [{ 'x': 4 }, { 'x': 5 }];
arrays

sortedIndexOf

This method is like indexOf except that it performs a binary search on a sorted array.

Example:

sortedIndexOf([4, 5, 5, 5, 6], 5); // 1
arrays

sortedLastIndex

This method is like sortedIndex except that it returns the highest index at which value should be inserted into array in order to maintain its sort order.

Example:

sortedLastIndex([4, 5, 5, 5, 6], 5); // 4
arrays

sortedLastIndexBy

This method is like sortedLastIndex except that it accepts iteratee which is invoked for value and each element of array to compute their sort ranking.

Example:

const objects = [{ 'x': 4 }, { 'x': 5 }];
arrays

sortedLastIndexOf

This method is like lastIndexOf except that it performs a binary search on a sorted array.

Example:

sortedLastIndexOf([4, 5, 5, 5, 6], 5); // 3
arrays

sortedUniq

This method is like uniq except that it's designed and optimized for sorted arrays.

Example:

sortedUniq([1, 1, 2]); // [1, 2]
arrays

sortedUniqBy

This method is like uniqBy except that it's designed and optimized for sorted arrays.

Example:

sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); // [1.1, 2.3]
arrays

tail

Gets all but the first element of array.

Example:

tail([1, 2, 3]); // [2, 3]
arrays

take

Creates a slice of array with n elements taken from the beginning.

Example:

take([1, 2, 3]); // [1]
arrays

takeRight

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

Example:

takeRight([1, 2, 3]); // [3]
arrays

takeRightWhile

Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey.

Example:

const users = [
arrays

takeWhile

Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns falsey.

Example:

const users = [
arrays

union

Creates an array of unique values, in order, from all given arrays.

Example:

union([2], [1, 2]); // [2, 1]
arrays

unionBy

This method is like union except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which uniqueness is computed.

Example:

unionBy([2.1], [1.2, 2.3], Math.floor); // [2.1, 1.2]
arrays

unionWith

This method is like union except that it accepts comparator which is invoked to compare elements of arrays.

Example:

const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
arrays

uniq

Creates a duplicate-free version of an array.

Example:

uniq([2, 1, 2]); // [2, 1]
arrays

uniqBy

This method is like uniq except that it accepts iteratee which is invoked for each element in array to generate the criterion by which uniqueness is computed.

Example:

uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]
arrays

uniqWith

This method is like uniq except that it accepts comparator which is invoked to compare elements of array.

Example:

const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
arrays

unzip

This method is like zip except that it accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.

Example:

const zipped = zip(['a', 'b'], [1, 2], [true, false]);
arrays

unzipWith

This method is like unzip except that it accepts iteratee to specify how regrouped values should be combined.

Example:

const zipped = zip([1, 2], [10, 20], [100, 200]);
arrays

without

Creates an array excluding all given values.

Example:

without([2, 1, 2, 3], 1, 2); // [3]
arrays

xor

Creates an array of unique values that is the symmetric difference of the given arrays.

Example:

xor([2, 1], [2, 3]); // [1, 3]
arrays

xorBy

This method is like xor except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which they're compared.

Example:

xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [1.2, 3.4]
arrays

xorWith

This method is like xor except that it accepts comparator which is invoked to compare elements of arrays.

Example:

const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
arrays

zip

Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on.

Example:

zip(['a', 'b'], [1, 2], [true, false]); // [['a', 1, true], ['b', 2, false]]
arrays

zipObject

This method is like fromPairs except that it accepts two arrays, one of property identifiers and one of corresponding values.

Example:

zipObject(['a', 'b'], [1, 2]); // { 'a': 1, 'b': 2 }
arrays

zipObjectDeep

This method is like zipObject except that it supports property paths.

Example:

zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
arrays

zipWith

This method is like zip except that it accepts iteratee to specify how grouped values should be combined.

Example:

zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c);
collection

countBy

Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The corresponding value of each key is the number of times the key was returned by iteratee.

Example:

countBy([6.1, 4.2, 6.3], Math.floor); // { '4': 1, '6': 2 }
collection

each

Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection).

Example:

each([1, 2], (value) => console.log(value)); // Logs `1` then `2`
collection

eachRight

This method is like each except that it iterates over elements of collection from right to left.

Example:

eachRight([1, 2], (value) => console.log(value)); // Logs `2` then `1`
collection

every

Checks if predicate returns truthy for all elements of collection.

Example:

every([true, 1, null, 'yes'], Boolean); // false
collection

filter

Iterates over elements of collection, returning an array of all elements predicate returns truthy for.

Example:

const users = [
collection

find

Iterates over elements of collection, returning the first element predicate returns truthy for.

Example:

const users = [
collection

findLast

This method is like find except that it iterates over elements of collection from right to left.

Example:

findLast([1, 2, 3, 4], (n) => n % 2 === 1); // 3
collection

flatMap

Creates a flattened array of values by running each element in collection thru iteratee and flattening the mapped results.

Example:

function duplicate(n: number) {
collection

flatMapDeep

This method is like flatMap except that it recursively flattens the mapped results.

Example:

function duplicate(n: number) {
collection

flatMapDepth

This method is like flatMap except that it recursively flattens the mapped results up to depth times.

Example:

function duplicate(n: number) {
collection

forEach

Iterates over elements of collection and invokes iteratee for each element.

Example:

forEach([1, 2], (value) => console.log(value)); // Logs `1` then `2`
collection

forEachRight

This method is like forEach except that it iterates over elements of collection from right to left.

Example:

forEachRight([1, 2], (value) => console.log(value)); // Logs `2` then `1`
collection

groupBy

Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The order of grouped values is determined by the order they occur in collection.

Example:

groupBy([6.1, 4.2, 6.3], Math.floor); // { '4': [4.2], '6': [6.1, 6.3] }
collection

includes

Checks if value is in collection.

Example:

includes([1, 2, 3], 1); // true
collection

invokeMap

Invokes the method at path of each element in collection, returning an array of the results of each invoked method.

Example:

invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); // [[1, 5, 7], [1, 2, 3]]
collection

keyBy

Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The corresponding value of each key is the last element responsible for generating the key.

Example:

const array = [
collection

map

Creates an array of values by running each element in collection thru iteratee.

Example:

function square(n: number) {
collection

orderBy

This method is like sortBy except that it allows specifying the sort orders of the iteratees to sort by.

Example:

const users = [
collection

partition

Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, the second of which contains elements predicate returns falsey for.

Example:

const users = [
collection

reduce

Reduces collection to a value which is the accumulated result of running each element in collection thru iteratee.

Example:

reduce([1, 2], (sum, n) => sum + n, 0); // 3
collection

reduceRight

This method is like reduce except that it iterates over elements of collection from right to left.

Example:

const array = [[0, 1], [2, 3], [4, 5]];
collection

reject

The opposite of filter; this method returns the elements of collection that predicate does not return truthy for.

Example:

const users = [
collection

sample

Gets a random element from collection.

Example:

sample([1, 2, 3, 4]); // 2 (random)
collection

sampleSize

Gets n random elements at unique keys from collection up to the size of collection.

Example:

sampleSize([1, 2, 3], 2); // [3, 1] (random)
collection

shuffle

Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.

Example:

shuffle([1, 2, 3, 4]); // [4, 1, 3, 2] (random)
collection

size

Gets the size of collection by returning its length for array-like values or the number of own enumerable string keyed properties for objects.

Example:

size([1, 2, 3]); // 3
collection

some

Checks if predicate returns truthy for any element of collection.

Example:

some([null, 0, 'yes', false], Boolean); // true
collection

sortBy

Creates an array of elements, sorted in ascending order by the results of running each element in a collection thru each iteratee.

Example:

const users = [
date

now

Gets the timestamp of the number of milliseconds that have elapsed since the Unix epoch.

Example:

const timestamp = now(); // e.g., 1699123456789
function

after

The opposite of before; this method creates a function that invokes func once it's called n or more times.

Example:

const saves = ['profile', 'settings'];
function

ary

Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.

Example:

map(['6', '8', '10'], ary(parseInt, 1)); // [6, 8, 10]
function

before

Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times.

Example:

jQuery(element).on('click', before(5, addContactToList));
function

bind

Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.

Example:

const greet = function(greeting: string, punctuation: string) {
function

bindKey

Creates a function that invokes the method at object[key] with partials prepended to the arguments it receives.

Example:

const object = {
function

curry

Creates a function that accepts arguments of func and either invokes func returning its result, or returns a function that accepts the remaining arguments.

Example:

const abc = (a: string, b: string, c: string) => [a, b, c];
function

curryRight

This method is like curry except that arguments are applied to func in the manner of partialRight instead of partial.

Example:

const abc = (a: string, b: string, c: string) => [a, b, c];
function

debounce

Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.

Example:

const debounced = debounce(() => console.log('hello'), 1000);
function

defer

Defers invoking the func until the current call stack has cleared.

Example:

defer((text: string) => console.log(text), 'deferred'); // Logs 'deferred' after one millisecond.
function

delay

Invokes func after wait milliseconds.

Example:

delay((text: string) => console.log(text), 1000, 'later'); // Logs 'later' after one second.
function

flip

Creates a function that invokes func with arguments reversed.

Example:

const flipped = flip((...args: unknown[]) => args);
function

memoize

Creates a function that memoizes the result of func.

Example:

const object = { 'a': 1, 'b': 2 };
function

negate

Creates a function that negates the result of the predicate func.

Example:

const isEven = (n: number) => n % 2 === 0;
function

once

Creates a function that is restricted to invoking func once.

Example:

const initialize = once(() => console.log('initialized'));
function

overArgs

Creates a function that invokes func with its arguments transformed.

Example:

function doubled(n: number) {
function

partial

Creates a function that invokes func with partials prepended to the arguments it receives.

Example:

function greet(greeting: string, name: string) {
function

partialRight

This method is like partial except that partials are appended to the arguments it receives.

Example:

function greet(greeting: string, name: string) {
function

rearg

Creates a function that invokes func with arguments arranged according to the specified indexes.

Example:

const rearged = rearg((a: string, b: string, c: string) => [a, b, c], [2, 0, 1]);
function

rest

Creates a function that invokes func with the this binding of the created function and arguments from start and beyond provided as an array.

Example:

const say = rest((what: string, names: string[]) => what + ' ' + names.join(', '));
function

spread

Creates a function that invokes func with the array of arguments provided to the created function.

Example:

const say = spread((who: string, what: string) => who + ' says ' + what);
function

throttle

Creates a throttled function that only invokes func at most once per every wait milliseconds.

Example:

const throttled = throttle(() => console.log('hello'), 1000);
function

unary

Creates a function that accepts up to one argument, ignoring any additional arguments.

Example:

map(['6', '8', '10'], unary(parseInt)); // [6, 8, 10]
function

wrap

Creates a function that provides value to wrapper as its first argument.

Example:

const p = wrap(escape, (func: typeof escape, text: string) => '<p>' + func(text) + '</p>');
lang

castArray

Casts value as an array if it's not one.

Example:

castArray(1); // [1]
lang

clone

Creates a shallow clone of value.

Example:

const objects = [{ 'a': 1 }, { 'b': 2 }];
lang

cloneDeep

This method is like clone except that it recursively clones value.

Example:

const objects = [{ 'a': 1 }, { 'b': 2 }];
lang

cloneDeepWith

This method is like cloneDeep except that it accepts customizer which is invoked to produce the cloned value.

Example:

function customizer(value: unknown) {
lang

cloneWith

This method is like clone except that it accepts customizer which is invoked to produce the cloned value.

Example:

function customizer(value: unknown) {
lang

conformsTo

Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.

Example:

const object = { 'a': 1, 'b': 2 };
lang

eq

Performs a SameValueZero comparison between two values to determine if they are equivalent.

Example:

const object = { 'a': 1 };
lang

gt

Checks if value is greater than other.

Example:

gt(3, 1); // true
lang

gte

Checks if value is greater than or equal to other.

Example:

gte(3, 1); // true
lang

isArguments

Checks if value is likely an arguments object.

Example:

isArguments(function() { return arguments; }()); // true
lang

isArray

Checks if value is classified as an Array object.

Example:

isArray([1, 2, 3]); // true
lang

isArrayBuffer

Checks if value is classified as an ArrayBuffer object.

Example:

isArrayBuffer(new ArrayBuffer(2)); // true
lang

isArrayLike

Checks if value is array-like.

Example:

isArrayLike([1, 2, 3]); // true
lang

isArrayLikeObject

This method is like isArrayLike except that it also checks if value is an object.

Example:

isArrayLikeObject([1, 2, 3]); // true
lang

isBoolean

Checks if value is classified as a Boolean primitive or object.

Example:

isBoolean(false); // true
lang

isBuffer

Checks if value is a Buffer. Note: This method returns false in browser environments.

Example:

isBuffer(Buffer.alloc(2)); // true (Node.js)
lang

isDate

Checks if value is classified as a Date object.

Example:

isDate(new Date); // true
lang

isElement

Checks if value is likely a DOM element.

Example:

isElement(document.body); // true
lang

isEmpty

Checks if value is an empty object, collection, map, or set.

Example:

isEmpty(null); // true
lang

isEqual

Performs a deep comparison between two values to determine if they are equivalent.

Example:

const object = { 'a': 1 };
lang

isEqualWith

This method is like isEqual except that it accepts customizer which is invoked to compare values.

Example:

function isGreeting(value: unknown) {
lang

isError

Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError object.

Example:

isError(new Error); // true
lang

isFinite

Checks if value is a finite primitive number.

Example:

isFinite(3); // true
lang

isFunction

Checks if value is classified as a Function object.

Example:

isFunction(() => {}); // true
lang

isInteger

Checks if value is an integer.

Example:

isInteger(3); // true
lang

isLength

Checks if value is a valid array-like length.

Example:

isLength(3); // true
lang

isMap

Checks if value is classified as a Map object.

Example:

isMap(new Map); // true
lang

isMatch

Performs a partial deep comparison between object and source to determine if object contains equivalent property values.

Example:

const object = { 'a': 1, 'b': 2 };
lang

isMatchWith

This method is like isMatch except that it accepts customizer which is invoked to compare values.

Example:

function isGreeting(value: unknown) {
lang

isNaN

Checks if value is NaN.

Example:

isNaN(NaN); // true
lang

isNative

Checks if value is a native function.

Example:

isNative(Array.prototype.push); // true
lang

isNil

Checks if value is null or undefined.

Example:

isNil(null); // true
lang

isNull

Checks if value is null.

Example:

isNull(null); // true
lang

isNumber

Checks if value is classified as a Number primitive or object.

Example:

isNumber(3); // true
lang

isObject

Checks if value is the language type of Object.

Example:

isObject({}); // true
lang

isObjectLike

Checks if value is object-like.

Example:

isObjectLike({}); // true
lang

isPlainObject

Checks if value is a plain object.

Example:

function Foo() {
lang

isRegExp

Checks if value is classified as a RegExp object.

Example:

isRegExp(/abc/); // true
lang

isSafeInteger

Checks if value is a safe integer.

Example:

isSafeInteger(3); // true
lang

isSet

Checks if value is classified as a Set object.

Example:

isSet(new Set); // true
lang

isString

Checks if value is classified as a String primitive or object.

Example:

isString('abc'); // true
lang

isSymbol

Checks if value is classified as a Symbol primitive or object.

Example:

isSymbol(Symbol.iterator); // true
lang

isTypedArray

Checks if value is classified as a typed array.

Example:

isTypedArray(new Uint8Array); // true
lang

isUndefined

Checks if value is undefined.

Example:

isUndefined(void 0); // true
lang

isWeakMap

Checks if value is classified as a WeakMap object.

Example:

isWeakMap(new WeakMap); // true
lang

isWeakSet

Checks if value is classified as a WeakSet object.

Example:

isWeakSet(new WeakSet); // true
lang

lt

Checks if value is less than other.

Example:

lt(1, 3); // true
lang

lte

Checks if value is less than or equal to other.

Example:

lte(1, 3); // true
lang

toArray

Converts value to an array.

Example:

toArray({ 'a': 1, 'b': 2 }); // [1, 2]
lang

toFinite

Converts value to a finite number.

Example:

toFinite(3.2); // 3.2
lang

toInteger

Converts value to an integer.

Example:

toInteger(3.2); // 3
lang

toLength

Converts value to an integer suitable for use as the length of an array-like object.

Example:

toLength(3.2); // 3
lang

toNumber

Converts value to a number.

Example:

toNumber(3.2); // 3.2
lang

toPlainObject

Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object.

Example:

function Foo() {
lang

toSafeInteger

Converts value to a safe integer.

Example:

toSafeInteger(3.2); // 3
lang

toString

Converts value to a string.

Example:

toString(null); // ''
math

add

Adds two numbers.

Example:

add(6, 4); // 10
math

ceil

Computes number rounded up to precision.

Example:

ceil(4.006); // 5
math

divide

Divide two numbers.

Example:

divide(6, 4); // 1.5
math

floor

Computes number rounded down to precision.

Example:

floor(4.006); // 4
math

max

Computes the maximum value of array.

Example:

max([4, 2, 8, 6]); // 8
math

maxBy

This method is like max except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.

Example:

const objects = [{ 'n': 1 }, { 'n': 2 }];
math

mean

Computes the mean of the values in array.

Example:

mean([4, 2, 8, 6]); // 5
math

meanBy

This method is like mean except that it accepts iteratee which is invoked for each element in array to generate the value to be averaged.

Example:

const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
math

min

Computes the minimum value of array.

Example:

min([4, 2, 8, 6]); // 2
math

minBy

This method is like min except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.

Example:

const objects = [{ 'n': 1 }, { 'n': 2 }];
math

multiply

Multiply two numbers.

Example:

multiply(6, 4); // 24
math

round

Computes number rounded to precision.

Example:

round(4.006); // 4
math

subtract

Subtract two numbers.

Example:

subtract(6, 4); // 2
math

sum

Computes the sum of the values in array.

Example:

sum([4, 2, 8, 6]); // 20
math

sumBy

This method is like sum except that it accepts iteratee which is invoked for each element in array to generate the value to be summed.

Example:

const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
number

clamp

Clamps a number between a lower and upper bound.

Example:

clamp(-10, -5, 5); // -5
number

inRange

Checks if a number is between start and up to, but not including, end. If end is not specified, it's set to start with start then 0.

Example:

inRange(3, 2, 4); // true
number

random

Produces a random number between the inclusive lower and upper bounds. If only one argument is provided, a number between 0 and the given number is returned. If floating is true, or either lower or upper are floats, a floating-point number is returned instead of an integer.

Example:

random(0, 5); // an integer between 0 and 5
object

assign

Assigns own enumerable string keyed properties of source objects to the destination object.

Example:

function Foo() {
object

assignIn

This method is like assign except that it iterates over own and inherited source properties.

Example:

function Foo() {
object

assignInWith

This method is like assignIn except that it accepts customizer which is invoked to produce the assigned values.

Example:

function customizer(objValue: unknown, srcValue: unknown) {
object

assignWith

This method is like assign except that it accepts customizer which is invoked to produce the assigned values.

Example:

function customizer(objValue: unknown, srcValue: unknown) {
object

at

Creates an array of values corresponding to paths of object.

Example:

const object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
object

create

Creates an object that inherits from the prototype object.

Example:

function Shape() {
object

defaults

Assigns own enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined.

Example:

defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // { 'a': 1, 'b': 2 }
object

defaultsDeep

This method is like defaults except that it recursively assigns default properties.

Example:

defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); // { 'a': { 'b': 2, 'c': 3 } }
object

entries

Creates an array of own enumerable string keyed-value pairs for object.

Example:

function Foo() {
object

entriesIn

Creates an array of own and inherited enumerable string keyed-value pairs for object.

Example:

function Foo() {
object

extend

Assigns own enumerable string keyed properties of source objects to the destination object. This is an alias for assignIn.

Example:

extend({ 'a': 1 }, { 'b': 2 }); // { 'a': 1, 'b': 2 }
object

extendWith

This method is like extend except that it accepts customizer which is invoked to produce the assigned values.

Example:

function customizer(objValue: unknown, srcValue: unknown) {
object

findKey

This method is like find except that it returns the key of the first element predicate returns truthy for instead of the element itself.

Example:

const users = {
object

findLastKey

This method is like findKey except that it iterates over elements of a collection in the opposite order.

Example:

const users = {
object

forIn

Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property.

Example:

function Foo() {
object

forInRight

This method is like forIn except that it iterates over properties of object in the opposite order.

Example:

function Foo() {
object

forOwn

Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property.

Example:

function Foo() {
object

forOwnRight

This method is like forOwn except that it iterates over properties of object in the opposite order.

Example:

function Foo() {
object

functions

Creates an array of function property names from own enumerable properties of object.

Example:

function Foo() {
object

functionsIn

Creates an array of function property names from own and inherited enumerable properties of object.

Example:

function Foo() {
object

get

Gets the value at path of object.

Example:

const object = { 'a': [{ 'b': { 'c': 3 } }] };
object

has

Checks if path is a direct property of object.

Example:

const object = { 'a': { 'b': 2 } };
object

hasIn

Checks if path is a direct or inherited property of object.

Example:

const object = Object.create({ 'a': Object.create({ 'b': 2 }) });
object

invert

Creates an object composed of the inverted keys and values of object.

Example:

const object = { 'a': 1, 'b': 2, 'c': 1 };
object

invertBy

This method is like invert except that the inverted object is generated from the results of running each element of object thru iteratee.

Example:

const object = { 'a': 1, 'b': 2, 'c': 1 };
object

invoke

Invokes the method at path of object.

Example:

const object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
object

keys

Creates an array of the own enumerable property names of object.

Example:

function Foo() {
object

keysIn

Creates an array of the own and inherited enumerable property names of object.

Example:

function Foo() {
object

mapKeys

Creates an object with the same values as object and keys generated by running each own enumerable string keyed property of object thru iteratee.

Example:

mapKeys({ 'a': 1, 'b': 2 }, (value, key) => key + value); // { 'a1': 1, 'b2': 2 }
object

mapValues

Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee.

Example:

const users = {
object

merge

Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object.

Example:

const object = {
object

mergeWith

This method is like merge except that it accepts customizer which is invoked to produce the merged values of the destination and source properties.

Example:

function customizer(objValue: unknown, srcValue: unknown) {
object

omit

Creates an object composed of the own and inherited enumerable property paths of object that are not omitted.

Example:

const object = { 'a': 1, 'b': '2', 'c': 3 };
object

omitBy

Creates an object composed of the own and inherited enumerable string keyed properties of object that predicate doesn't return truthy for.

Example:

const object = { 'a': 1, 'b': '2', 'c': 3 };
object

pick

Creates an object composed of the picked object properties.

Example:

const object = { 'a': 1, 'b': '2', 'c': 3 };
object

pickBy

Creates an object composed of the object properties predicate returns truthy for.

Example:

const object = { 'a': 1, 'b': '2', 'c': 3 };
object

result

This method is like get except that if the resolved value is a function it's invoked with the this binding of its parent object and its result is returned.

Example:

const object = { 'a': [{ 'b': { 'c1': 3, 'c2': () => 4 } }] };
object

set

Sets the value at path of object.

Example:

const object = { 'a': [{ 'b': { 'c': 3 } }] };
object

setWith

This method is like set except that it accepts customizer which is invoked to produce the objects of path.

Example:

const object = {};
object

toPairs

Creates an array of own enumerable string keyed-value pairs for object. This is an alias for entries.

Example:

function Foo() {
object

toPairsIn

Creates an array of own and inherited enumerable string keyed-value pairs for object. This is an alias for entriesIn.

Example:

function Foo() {
object

transform

An alternative to reduce; this method transforms object to a new accumulator object which is the result of running each of its own enumerable string keyed properties thru iteratee.

Example:

transform([2, 3, 4], (result, n) => {
object

unset

Removes the property at path of object.

Example:

const object = { 'a': [{ 'b': { 'c': 7 } }] };
object

update

This method is like set except that it accepts updater to produce the value to set.

Example:

const object = { 'a': [{ 'b': { 'c': 3 } }] };
object

updateWith

This method is like update except that it accepts customizer which is invoked to produce the objects of path.

Example:

const object = {};
object

values

Creates an array of the own enumerable string keyed property values of object.

Example:

function Foo() {
object

valuesIn

Creates an array of the own and inherited enumerable string keyed property values of object.

Example:

function Foo() {
seq

chain

Creates a lodash wrapper instance that wraps value with explicit method chain sequences enabled.

Example:

const users = [
seq

tap

This method invokes interceptor and returns value.

Example:

tap([1, 2, 3], (array) => array.pop()); // [1, 2]
seq

thru

This method is like tap except that it returns the result of interceptor.

Example:

thru([1, 2, 3], (array) => array.reverse()); // [3, 2, 1]
string

camelCase

Converts string to camel case.

Example:

camelCase('Foo Bar'); // 'fooBar'
string

capitalize

Converts the first character of string to upper case and the remaining to lower case.

Example:

capitalize('FRED'); // 'Fred'
string

deburr

Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing combining diacritical marks.

Example:

deburr('déjà vu'); // 'deja vu'
string

endsWith

Checks if string ends with the given target string.

Example:

endsWith('abc', 'c'); // true
string

escape

Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.

Example:

escape('fred, barney, & pebbles'); // 'fred, barney, &amp; pebbles'
string

escapeRegExp

Escapes the RegExp special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.

Example:

escapeRegExp('[lodash](https://lodash.com/)'); // '\\[lodash\\]\\(https://lodash\\.com/\\)'
string

kebabCase

Converts string to kebab case.

Example:

kebabCase('Foo Bar'); // 'foo-bar'
string

lowerCase

Converts string, as space separated words, to lower case.

Example:

lowerCase('--Foo-Bar--'); // 'foo bar'
string

lowerFirst

Converts the first character of string to lower case.

Example:

lowerFirst('Fred'); // 'fred'
string

pad

Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.

Example:

pad('abc', 8); // ' abc '
string

padEnd

Pads string on the right side if it's shorter than length. Padding characters are truncated if they exceed length.

Example:

padEnd('abc', 6); // 'abc '
string

padStart

Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.

Example:

padStart('abc', 6); // ' abc'
string

parseInt

Converts string to an integer of the specified radix.

Example:

parseInt('08'); // 8
string

repeat

Repeats the given string n times.

Example:

repeat('*', 3); // '***'
string

replace

Replaces matches for pattern in string with replacement.

Example:

replace('Hi Fred', 'Fred', 'Barney'); // 'Hi Barney'
string

snakeCase

Converts string to snake case.

Example:

snakeCase('Foo Bar'); // 'foo_bar'
string

split

Splits string by separator.

Example:

split('a-b-c', '-', 2); // ['a', 'b']
string

startCase

Converts string to start case.

Example:

startCase('--foo-bar--'); // 'Foo Bar'
string

startsWith

Checks if string starts with the given target string.

Example:

startsWith('abc', 'a'); // true
string

toLower

Converts string, as a whole, to lower case.

Example:

toLower('--Foo-Bar--'); // '--foo-bar--'
string

toUpper

Converts string, as a whole, to upper case.

Example:

toUpper('--foo-bar--'); // '--FOO-BAR--'
string

trim

Removes leading and trailing whitespace or specified characters from string.

Example:

trim(' abc '); // 'abc'
string

trimEnd

Removes trailing whitespace or specified characters from string.

Example:

trimEnd(' abc '); // ' abc'
string

trimStart

Removes leading whitespace or specified characters from string.

Example:

trimStart(' abc '); // 'abc '
string

truncate

Truncates string if it's longer than the given maximum string length. The last characters of the truncated string are replaced with the omission string which defaults to "...".

Example:

truncate('hi-diddly-ho there, neighborino'); // 'hi-diddly-ho there, neighbo...'
string

unescape

The inverse of escape; this method converts the HTML entities &amp;, &lt;, &gt;, &quot;, and &#39; in string to their corresponding characters.

Example:

unescape('fred, barney, &amp; pebbles'); // 'fred, barney, & pebbles'
string

upperCase

Converts string, as space separated words, to upper case.

Example:

upperCase('--foo-bar--'); // 'FOO BAR'
string

upperFirst

Converts the first character of string to upper case.

Example:

upperFirst('fred'); // 'Fred'
string

words

Splits string into an array of its words.

Example:

words('fred, barney, & pebbles'); // ['fred', 'barney', 'pebbles']
util

attempt

Attempts to invoke func, returning either the result or the caught error object.

Example:

const elements = attempt((selector: string) => document.querySelectorAll(selector), '>_>');
util

bindAll

Binds methods of an object to the object itself, overwriting the existing method.

Example:

const view = {
util

cond

Creates a function that iterates over pairs and invokes the corresponding function of the first predicate to return truthy.

Example:

const func = cond([
util

conforms

Creates a function that invokes the predicate properties of source with the corresponding property values of a given object.

Example:

const objects = [
util

constant

Creates a function that returns value.

Example:

const objects = times(2, constant({ 'a': 1 }));
util

defaultTo

Checks value to determine whether a default value should be returned in its place.

Example:

defaultTo(1, 10); // 1
util

flow

Creates a function that returns the result of invoking the given functions with the this binding of the created function.

Example:

function square(n: number) {
util

flowRight

This method is like flow except that it creates a function that invokes the given functions from right to left.

Example:

function square(n: number) {
util

identity

This method returns the first argument it receives.

Example:

const object = { 'a': 1 };
util

iteratee

Creates a function that invokes the predicate at the path of a given object.

Example:

const users = [
util

matches

Creates a function that performs a partial deep comparison between a given object and source.

Example:

const objects = [
util

matchesProperty

Creates a function that performs a partial deep comparison between the value at path of a given object and srcValue.

Example:

const objects = [
util

method

Creates a function that invokes the method at path of a given object.

Example:

const objects = [
util

methodOf

The opposite of method; this method creates a function that invokes the method at a given path of object.

Example:

const array = [
util

mixin

Adds all own enumerable string keyed function properties of a source object to the destination object.

Example:

function vowels(string) {
util

noConflict

Reverts the _ variable to its previous value and returns a reference to the tulx object.

Example:

const tulx = noConflict();
util

noop

A no-operation function that returns undefined regardless of the arguments it receives.

Example:

const object = { 'user': 'fred' };
util

nthArg

Creates a function that gets the argument at index n.

Example:

const func = nthArg(1);
util

over

Creates a function that invokes iteratees with the arguments it receives and returns their results.

Example:

const func = over([Math.max, Math.min]);
util

overEvery

Creates a function that checks if all of the predicates return truthy when invoked with the arguments it receives.

Example:

const func = overEvery([Boolean, isFinite]);
util

overSome

Creates a function that checks if any of the predicates return truthy when invoked with the arguments it receives.

Example:

const func = overSome([Boolean, isFinite]);
util

property

Creates a function that returns the value at path of a given object.

Example:

const objects = [
util

propertyOf

The opposite of property; this method creates a function that returns the value at a given path of object.

Example:

const array = [0, 1, 2];
util

range

Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.

Example:

range(4); // [0, 1, 2, 3]
util

rangeRight

This method is like range except that it populates values in descending order.

Example:

rangeRight(4); // [3, 2, 1, 0]
util

runInContext

Create a new pristine lodash function using the given context object.

Example:

const _ = runInContext();
util

stubArray

This method returns a new empty array.

Example:

const arrays = times(2, stubArray);
util

stubFalse

This method returns false.

Example:

times(2, stubFalse); // [false, false]
util

stubObject

This method returns a new empty object.

Example:

const objects = times(2, stubObject);
util

stubString

This method returns an empty string.

Example:

times(2, stubString); // ['', '']
util

stubTrue

This method returns true.

Example:

times(2, stubTrue); // [true, true]
util

times

Invokes the iteratee n times, returning an array of the results of each invocation.

Example:

times(3, String); // ['0', '1', '2']
util

toPath

Converts value to a property path array.

Example:

toPath('a.b.c'); // ['a', 'b', 'c']
util

uniqueId

Generates a unique ID.

Example:

uniqueId('contact_'); // 'contact_1'