Functions
Browse all available utility functions by category
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']]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]concat
Creates a new array concatenating array with any additional arrays and/or values.
Example:
const array = [1];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]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]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 }];drop
Creates a slice of array with n elements dropped from the beginning.
Example:
drop([1, 2, 3]); // [2, 3]dropRight
Creates a slice of array with n elements dropped from the end.
Example:
dropRight([1, 2, 3]); // [1, 2]dropRightWhile
Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate returns falsey.
Example:
const users = [dropWhile
Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey.
Example:
const users = [fill
Fills elements of array with value from start up to, but not including, end.
Example:
const array = [1, 2, 3];findIndex
Returns the index of the first element predicate returns truthy for instead of the element itself.
Example:
const users = [findLastIndex
This method is like findIndex except that it iterates over elements of collection from right to left.
Example:
const users = [first
Gets the first element of array.
Example:
first([1, 2, 3]); // 1flatten
Flattens array a single level deep.
Example:
flatten([1, [2, [3, [4]], 5]]); // [1, 2, [3, [4]], 5]flattenDeep
Recursively flattens array.
Example:
flattenDeep([1, [2, [3, [4]], 5]]); // [1, 2, 3, 4, 5]flattenDepth
Recursively flatten array up to depth times.
Example:
const array = [1, [2, [3, [4]], 5]];fromPairs
Returns an object composed from key-value pairs.
Example:
fromPairs([['a', 1], ['b', 2]]); // { 'a': 1, 'b': 2 }head
Gets the first element of array.
Example:
head([1, 2, 3]); // 1indexOf
Gets the index at which the first occurrence of value is found in array.
Example:
indexOf([1, 2, 1, 2], 2); // 1initial
Gets all but the last element of array.
Example:
initial([1, 2, 3]); // [1, 2]intersection
Creates an array of unique values that are included in all given arrays.
Example:
intersection([2, 1], [2, 3]); // [2]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]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 }];join
Converts all elements in array into a string separated by separator.
Example:
join(['a', 'b', 'c'], '~'); // 'a~b~c'last
Gets the last element of array.
Example:
last([1, 2, 3]); // 3lastIndexOf
This method is like indexOf except that it iterates over elements of array from right to left.
Example:
lastIndexOf([1, 2, 1, 2], 2); // 3nth
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'];pull
Removes all given values from array.
Example:
const array = ['a', 'b', 'c', 'a', 'b', 'c'];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'];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 }];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 }];pullAt
Removes elements from array corresponding to indexes and returns an array of removed elements.
Example:
const array = ['a', 'b', 'c', 'd'];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];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];slice
Creates a slice of array from start up to, but not including, end.
Example:
const array = [1, 2, 3, 4];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); // 1sortedIndexBy
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 }];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); // 1sortedLastIndex
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); // 4sortedLastIndexBy
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 }];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); // 3sortedUniq
This method is like uniq except that it's designed and optimized for sorted arrays.
Example:
sortedUniq([1, 1, 2]); // [1, 2]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]tail
Gets all but the first element of array.
Example:
tail([1, 2, 3]); // [2, 3]take
Creates a slice of array with n elements taken from the beginning.
Example:
take([1, 2, 3]); // [1]takeRight
Creates a slice of array with n elements taken from the end.
Example:
takeRight([1, 2, 3]); // [3]takeRightWhile
Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey.
Example:
const users = [takeWhile
Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns falsey.
Example:
const users = [union
Creates an array of unique values, in order, from all given arrays.
Example:
union([2], [1, 2]); // [2, 1]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]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 }];uniq
Creates a duplicate-free version of an array.
Example:
uniq([2, 1, 2]); // [2, 1]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]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 }];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]);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]);without
Creates an array excluding all given values.
Example:
without([2, 1, 2, 3], 1, 2); // [3]xor
Creates an array of unique values that is the symmetric difference of the given arrays.
Example:
xor([2, 1], [2, 3]); // [1, 3]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]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 }];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]]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 }zipObjectDeep
This method is like zipObject except that it supports property paths.
Example:
zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);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);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 }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`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`every
Checks if predicate returns truthy for all elements of collection.
Example:
every([true, 1, null, 'yes'], Boolean); // falsefilter
Iterates over elements of collection, returning an array of all elements predicate returns truthy for.
Example:
const users = [find
Iterates over elements of collection, returning the first element predicate returns truthy for.
Example:
const users = [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); // 3flatMap
Creates a flattened array of values by running each element in collection thru iteratee and flattening the mapped results.
Example:
function duplicate(n: number) {flatMapDeep
This method is like flatMap except that it recursively flattens the mapped results.
Example:
function duplicate(n: number) {flatMapDepth
This method is like flatMap except that it recursively flattens the mapped results up to depth times.
Example:
function duplicate(n: number) {forEach
Iterates over elements of collection and invokes iteratee for each element.
Example:
forEach([1, 2], (value) => console.log(value)); // Logs `1` then `2`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`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] }includes
Checks if value is in collection.
Example:
includes([1, 2, 3], 1); // trueinvokeMap
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]]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 = [map
Creates an array of values by running each element in collection thru iteratee.
Example:
function square(n: number) {orderBy
This method is like sortBy except that it allows specifying the sort orders of the iteratees to sort by.
Example:
const users = [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 = [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); // 3reduceRight
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]];reject
The opposite of filter; this method returns the elements of collection that predicate does not return truthy for.
Example:
const users = [sample
Gets a random element from collection.
Example:
sample([1, 2, 3, 4]); // 2 (random)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)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)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]); // 3some
Checks if predicate returns truthy for any element of collection.
Example:
some([null, 0, 'yes', false], Boolean); // truesortBy
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 = [now
Gets the timestamp of the number of milliseconds that have elapsed since the Unix epoch.
Example:
const timestamp = now(); // e.g., 1699123456789after
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'];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]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));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) {bindKey
Creates a function that invokes the method at object[key] with partials prepended to the arguments it receives.
Example:
const object = {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];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];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);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.delay
Invokes func after wait milliseconds.
Example:
delay((text: string) => console.log(text), 1000, 'later'); // Logs 'later' after one second.flip
Creates a function that invokes func with arguments reversed.
Example:
const flipped = flip((...args: unknown[]) => args);memoize
Creates a function that memoizes the result of func.
Example:
const object = { 'a': 1, 'b': 2 };negate
Creates a function that negates the result of the predicate func.
Example:
const isEven = (n: number) => n % 2 === 0;once
Creates a function that is restricted to invoking func once.
Example:
const initialize = once(() => console.log('initialized'));overArgs
Creates a function that invokes func with its arguments transformed.
Example:
function doubled(n: number) {partial
Creates a function that invokes func with partials prepended to the arguments it receives.
Example:
function greet(greeting: string, name: string) {partialRight
This method is like partial except that partials are appended to the arguments it receives.
Example:
function greet(greeting: string, name: string) {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]);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(', '));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);throttle
Creates a throttled function that only invokes func at most once per every wait milliseconds.
Example:
const throttled = throttle(() => console.log('hello'), 1000);unary
Creates a function that accepts up to one argument, ignoring any additional arguments.
Example:
map(['6', '8', '10'], unary(parseInt)); // [6, 8, 10]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>');castArray
Casts value as an array if it's not one.
Example:
castArray(1); // [1]clone
Creates a shallow clone of value.
Example:
const objects = [{ 'a': 1 }, { 'b': 2 }];cloneDeep
This method is like clone except that it recursively clones value.
Example:
const objects = [{ 'a': 1 }, { 'b': 2 }];cloneDeepWith
This method is like cloneDeep except that it accepts customizer which is invoked to produce the cloned value.
Example:
function customizer(value: unknown) {cloneWith
This method is like clone except that it accepts customizer which is invoked to produce the cloned value.
Example:
function customizer(value: unknown) {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 };eq
Performs a SameValueZero comparison between two values to determine if they are equivalent.
Example:
const object = { 'a': 1 };gt
Checks if value is greater than other.
Example:
gt(3, 1); // truegte
Checks if value is greater than or equal to other.
Example:
gte(3, 1); // trueisArguments
Checks if value is likely an arguments object.
Example:
isArguments(function() { return arguments; }()); // trueisArray
Checks if value is classified as an Array object.
Example:
isArray([1, 2, 3]); // trueisArrayBuffer
Checks if value is classified as an ArrayBuffer object.
Example:
isArrayBuffer(new ArrayBuffer(2)); // trueisArrayLike
Checks if value is array-like.
Example:
isArrayLike([1, 2, 3]); // trueisArrayLikeObject
This method is like isArrayLike except that it also checks if value is an object.
Example:
isArrayLikeObject([1, 2, 3]); // trueisBoolean
Checks if value is classified as a Boolean primitive or object.
Example:
isBoolean(false); // trueisBuffer
Checks if value is a Buffer. Note: This method returns false in browser environments.
Example:
isBuffer(Buffer.alloc(2)); // true (Node.js)isDate
Checks if value is classified as a Date object.
Example:
isDate(new Date); // trueisElement
Checks if value is likely a DOM element.
Example:
isElement(document.body); // trueisEmpty
Checks if value is an empty object, collection, map, or set.
Example:
isEmpty(null); // trueisEqual
Performs a deep comparison between two values to determine if they are equivalent.
Example:
const object = { 'a': 1 };isEqualWith
This method is like isEqual except that it accepts customizer which is invoked to compare values.
Example:
function isGreeting(value: unknown) {isError
Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError object.
Example:
isError(new Error); // trueisFinite
Checks if value is a finite primitive number.
Example:
isFinite(3); // trueisFunction
Checks if value is classified as a Function object.
Example:
isFunction(() => {}); // trueisInteger
Checks if value is an integer.
Example:
isInteger(3); // trueisLength
Checks if value is a valid array-like length.
Example:
isLength(3); // trueisMap
Checks if value is classified as a Map object.
Example:
isMap(new Map); // trueisMatch
Performs a partial deep comparison between object and source to determine if object contains equivalent property values.
Example:
const object = { 'a': 1, 'b': 2 };isMatchWith
This method is like isMatch except that it accepts customizer which is invoked to compare values.
Example:
function isGreeting(value: unknown) {isNaN
Checks if value is NaN.
Example:
isNaN(NaN); // trueisNative
Checks if value is a native function.
Example:
isNative(Array.prototype.push); // trueisNil
Checks if value is null or undefined.
Example:
isNil(null); // trueisNull
Checks if value is null.
Example:
isNull(null); // trueisNumber
Checks if value is classified as a Number primitive or object.
Example:
isNumber(3); // trueisObject
Checks if value is the language type of Object.
Example:
isObject({}); // trueisObjectLike
Checks if value is object-like.
Example:
isObjectLike({}); // trueisPlainObject
Checks if value is a plain object.
Example:
function Foo() {isRegExp
Checks if value is classified as a RegExp object.
Example:
isRegExp(/abc/); // trueisSafeInteger
Checks if value is a safe integer.
Example:
isSafeInteger(3); // trueisSet
Checks if value is classified as a Set object.
Example:
isSet(new Set); // trueisString
Checks if value is classified as a String primitive or object.
Example:
isString('abc'); // trueisSymbol
Checks if value is classified as a Symbol primitive or object.
Example:
isSymbol(Symbol.iterator); // trueisTypedArray
Checks if value is classified as a typed array.
Example:
isTypedArray(new Uint8Array); // trueisUndefined
Checks if value is undefined.
Example:
isUndefined(void 0); // trueisWeakMap
Checks if value is classified as a WeakMap object.
Example:
isWeakMap(new WeakMap); // trueisWeakSet
Checks if value is classified as a WeakSet object.
Example:
isWeakSet(new WeakSet); // truelt
Checks if value is less than other.
Example:
lt(1, 3); // truelte
Checks if value is less than or equal to other.
Example:
lte(1, 3); // truetoArray
Converts value to an array.
Example:
toArray({ 'a': 1, 'b': 2 }); // [1, 2]toFinite
Converts value to a finite number.
Example:
toFinite(3.2); // 3.2toInteger
Converts value to an integer.
Example:
toInteger(3.2); // 3toLength
Converts value to an integer suitable for use as the length of an array-like object.
Example:
toLength(3.2); // 3toNumber
Converts value to a number.
Example:
toNumber(3.2); // 3.2toPlainObject
Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object.
Example:
function Foo() {toSafeInteger
Converts value to a safe integer.
Example:
toSafeInteger(3.2); // 3toString
Converts value to a string.
Example:
toString(null); // ''add
Adds two numbers.
Example:
add(6, 4); // 10ceil
Computes number rounded up to precision.
Example:
ceil(4.006); // 5divide
Divide two numbers.
Example:
divide(6, 4); // 1.5floor
Computes number rounded down to precision.
Example:
floor(4.006); // 4max
Computes the maximum value of array.
Example:
max([4, 2, 8, 6]); // 8maxBy
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 }];mean
Computes the mean of the values in array.
Example:
mean([4, 2, 8, 6]); // 5meanBy
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 }];min
Computes the minimum value of array.
Example:
min([4, 2, 8, 6]); // 2minBy
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 }];multiply
Multiply two numbers.
Example:
multiply(6, 4); // 24round
Computes number rounded to precision.
Example:
round(4.006); // 4subtract
Subtract two numbers.
Example:
subtract(6, 4); // 2sum
Computes the sum of the values in array.
Example:
sum([4, 2, 8, 6]); // 20sumBy
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 }];clamp
Clamps a number between a lower and upper bound.
Example:
clamp(-10, -5, 5); // -5inRange
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); // truerandom
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 5assign
Assigns own enumerable string keyed properties of source objects to the destination object.
Example:
function Foo() {assignIn
This method is like assign except that it iterates over own and inherited source properties.
Example:
function Foo() {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) {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) {at
Creates an array of values corresponding to paths of object.
Example:
const object = { 'a': [{ 'b': { 'c': 3 } }, 4] };create
Creates an object that inherits from the prototype object.
Example:
function Shape() {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 }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 } }entries
Creates an array of own enumerable string keyed-value pairs for object.
Example:
function Foo() {entriesIn
Creates an array of own and inherited enumerable string keyed-value pairs for object.
Example:
function Foo() {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 }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) {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 = {findLastKey
This method is like findKey except that it iterates over elements of a collection in the opposite order.
Example:
const users = {forIn
Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property.
Example:
function Foo() {forInRight
This method is like forIn except that it iterates over properties of object in the opposite order.
Example:
function Foo() {forOwn
Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property.
Example:
function Foo() {forOwnRight
This method is like forOwn except that it iterates over properties of object in the opposite order.
Example:
function Foo() {functions
Creates an array of function property names from own enumerable properties of object.
Example:
function Foo() {functionsIn
Creates an array of function property names from own and inherited enumerable properties of object.
Example:
function Foo() {get
Gets the value at path of object.
Example:
const object = { 'a': [{ 'b': { 'c': 3 } }] };has
Checks if path is a direct property of object.
Example:
const object = { 'a': { 'b': 2 } };hasIn
Checks if path is a direct or inherited property of object.
Example:
const object = Object.create({ 'a': Object.create({ 'b': 2 }) });invert
Creates an object composed of the inverted keys and values of object.
Example:
const object = { 'a': 1, 'b': 2, 'c': 1 };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 };invoke
Invokes the method at path of object.
Example:
const object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };keys
Creates an array of the own enumerable property names of object.
Example:
function Foo() {keysIn
Creates an array of the own and inherited enumerable property names of object.
Example:
function Foo() {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 }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 = {merge
Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object.
Example:
const 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) {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 };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 };pick
Creates an object composed of the picked object properties.
Example:
const object = { 'a': 1, 'b': '2', 'c': 3 };pickBy
Creates an object composed of the object properties predicate returns truthy for.
Example:
const object = { 'a': 1, 'b': '2', 'c': 3 };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 } }] };set
Sets the value at path of object.
Example:
const object = { 'a': [{ 'b': { 'c': 3 } }] };setWith
This method is like set except that it accepts customizer which is invoked to produce the objects of path.
Example:
const object = {};toPairs
Creates an array of own enumerable string keyed-value pairs for object. This is an alias for entries.
Example:
function Foo() {toPairsIn
Creates an array of own and inherited enumerable string keyed-value pairs for object. This is an alias for entriesIn.
Example:
function Foo() {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) => {unset
Removes the property at path of object.
Example:
const object = { 'a': [{ 'b': { 'c': 7 } }] };update
This method is like set except that it accepts updater to produce the value to set.
Example:
const object = { 'a': [{ 'b': { 'c': 3 } }] };updateWith
This method is like update except that it accepts customizer which is invoked to produce the objects of path.
Example:
const object = {};values
Creates an array of the own enumerable string keyed property values of object.
Example:
function Foo() {valuesIn
Creates an array of the own and inherited enumerable string keyed property values of object.
Example:
function Foo() {chain
Creates a lodash wrapper instance that wraps value with explicit method chain sequences enabled.
Example:
const users = [tap
This method invokes interceptor and returns value.
Example:
tap([1, 2, 3], (array) => array.pop()); // [1, 2]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]camelCase
Converts string to camel case.
Example:
camelCase('Foo Bar'); // 'fooBar'capitalize
Converts the first character of string to upper case and the remaining to lower case.
Example:
capitalize('FRED'); // 'Fred'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'endsWith
Checks if string ends with the given target string.
Example:
endsWith('abc', 'c'); // trueescape
Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.
Example:
escape('fred, barney, & pebbles'); // 'fred, barney, & pebbles'escapeRegExp
Escapes the RegExp special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.
Example:
escapeRegExp('[lodash](https://lodash.com/)'); // '\\[lodash\\]\\(https://lodash\\.com/\\)'kebabCase
Converts string to kebab case.
Example:
kebabCase('Foo Bar'); // 'foo-bar'lowerCase
Converts string, as space separated words, to lower case.
Example:
lowerCase('--Foo-Bar--'); // 'foo bar'lowerFirst
Converts the first character of string to lower case.
Example:
lowerFirst('Fred'); // 'fred'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 '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 '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'parseInt
Converts string to an integer of the specified radix.
Example:
parseInt('08'); // 8repeat
Repeats the given string n times.
Example:
repeat('*', 3); // '***'replace
Replaces matches for pattern in string with replacement.
Example:
replace('Hi Fred', 'Fred', 'Barney'); // 'Hi Barney'snakeCase
Converts string to snake case.
Example:
snakeCase('Foo Bar'); // 'foo_bar'split
Splits string by separator.
Example:
split('a-b-c', '-', 2); // ['a', 'b']startCase
Converts string to start case.
Example:
startCase('--foo-bar--'); // 'Foo Bar'startsWith
Checks if string starts with the given target string.
Example:
startsWith('abc', 'a'); // truetoLower
Converts string, as a whole, to lower case.
Example:
toLower('--Foo-Bar--'); // '--foo-bar--'toUpper
Converts string, as a whole, to upper case.
Example:
toUpper('--foo-bar--'); // '--FOO-BAR--'trim
Removes leading and trailing whitespace or specified characters from string.
Example:
trim(' abc '); // 'abc'trimEnd
Removes trailing whitespace or specified characters from string.
Example:
trimEnd(' abc '); // ' abc'trimStart
Removes leading whitespace or specified characters from string.
Example:
trimStart(' abc '); // 'abc '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...'unescape
The inverse of escape; this method converts the HTML entities &, <, >, ", and ' in string to their corresponding characters.
Example:
unescape('fred, barney, & pebbles'); // 'fred, barney, & pebbles'upperCase
Converts string, as space separated words, to upper case.
Example:
upperCase('--foo-bar--'); // 'FOO BAR'upperFirst
Converts the first character of string to upper case.
Example:
upperFirst('fred'); // 'Fred'words
Splits string into an array of its words.
Example:
words('fred, barney, & pebbles'); // ['fred', 'barney', 'pebbles']attempt
Attempts to invoke func, returning either the result or the caught error object.
Example:
const elements = attempt((selector: string) => document.querySelectorAll(selector), '>_>');bindAll
Binds methods of an object to the object itself, overwriting the existing method.
Example:
const view = {cond
Creates a function that iterates over pairs and invokes the corresponding function of the first predicate to return truthy.
Example:
const func = cond([conforms
Creates a function that invokes the predicate properties of source with the corresponding property values of a given object.
Example:
const objects = [constant
Creates a function that returns value.
Example:
const objects = times(2, constant({ 'a': 1 }));defaultTo
Checks value to determine whether a default value should be returned in its place.
Example:
defaultTo(1, 10); // 1flow
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) {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) {identity
This method returns the first argument it receives.
Example:
const object = { 'a': 1 };iteratee
Creates a function that invokes the predicate at the path of a given object.
Example:
const users = [matches
Creates a function that performs a partial deep comparison between a given object and source.
Example:
const objects = [matchesProperty
Creates a function that performs a partial deep comparison between the value at path of a given object and srcValue.
Example:
const objects = [method
Creates a function that invokes the method at path of a given object.
Example:
const objects = [methodOf
The opposite of method; this method creates a function that invokes the method at a given path of object.
Example:
const array = [mixin
Adds all own enumerable string keyed function properties of a source object to the destination object.
Example:
function vowels(string) {noConflict
Reverts the _ variable to its previous value and returns a reference to the tulx object.
Example:
const tulx = noConflict();noop
A no-operation function that returns undefined regardless of the arguments it receives.
Example:
const object = { 'user': 'fred' };nthArg
Creates a function that gets the argument at index n.
Example:
const func = nthArg(1);over
Creates a function that invokes iteratees with the arguments it receives and returns their results.
Example:
const func = over([Math.max, Math.min]);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]);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]);property
Creates a function that returns the value at path of a given object.
Example:
const objects = [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];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]rangeRight
This method is like range except that it populates values in descending order.
Example:
rangeRight(4); // [3, 2, 1, 0]runInContext
Create a new pristine lodash function using the given context object.
Example:
const _ = runInContext();stubArray
This method returns a new empty array.
Example:
const arrays = times(2, stubArray);stubFalse
This method returns false.
Example:
times(2, stubFalse); // [false, false]stubObject
This method returns a new empty object.
Example:
const objects = times(2, stubObject);stubString
This method returns an empty string.
Example:
times(2, stubString); // ['', '']stubTrue
This method returns true.
Example:
times(2, stubTrue); // [true, true]times
Invokes the iteratee n times, returning an array of the results of each invocation.
Example:
times(3, String); // ['0', '1', '2']toPath
Converts value to a property path array.
Example:
toPath('a.b.c'); // ['a', 'b', 'c']uniqueId
Generates a unique ID.
Example:
uniqueId('contact_'); // 'contact_1'