Functions

Browse all available utility functions by category

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); // ''