_.castArray(value)_.clone(value)_.cloneDeep(value)_.cloneDeepWith(value, [customizer])_.cloneWith(value, [customizer])_.conformsTo(object, source)_.eq(value, other)_.gt(value, other)_.gte(value, other)_.isArguments(value)_.isArray(value)_.isArrayBuffer(value)_.isArrayLike(value)_.isArrayLikeObject(value)_.isBoolean(value)_.isBuffer(value)_.isDate(value)_.isElement(value)_.isEmpty(value)_.isEqual(value, other)_.isEqualWith(value, other, [customizer])_.isError(value)_.isFinite(value)_.isFunction(value)_.isInteger(value)_.isLength(value)_.isMap(value)_.isMatch(object, source)_.isMatchWith(object, source, [customizer])_.isNaN(value)_.isNative(value)_.isNil(value)_.isNull(value)_.isNumber(value)_.isObject(value)_.isObjectLike(value)_.isPlainObject(value)_.isRegExp(value)_.isSafeInteger(value)_.isSet(value)_.isString(value)_.isSymbol(value)_.isTypedArray(value)_.isUndefined(value)_.isWeakMap(value)_.isWeakSet(value)_.lt(value, other)_.lte(value, other)_.toArray(value)_.toFinite(value)_.toInteger(value)_.toLength(value)_.toNumber(value)_.toPlainObject(value)_.toSafeInteger(value)_.toString(value)
_.castArray(value)
Casts value as an array if it’s not one.
Since
4.4.0
Arguments
value(*): The value to inspect.
Returns
(Array): Returns the cast array.
Example
_.castArray(1);// => [1]_.castArray({ 'a': 1 });// => [{ 'a': 1 }]_.castArray('abc');// => ['abc']_.castArray(null);// => [null]_.castArray(undefined);// => [undefined]_.castArray();// => []var array = [1, 2, 3];console.log(_.castArray(array) === array);// => true
_.clone(value)
Creates a shallow clone of value.
Note: This method is loosely based on the
structured clone algorithm
and supports cloning arrays, array buffers, booleans, date objects, maps,
numbers, Object objects, regexes, sets, strings, symbols, and typed
arrays. The own enumerable properties of arguments objects are cloned
as plain objects. An empty object is returned for uncloneable values such
as error objects, functions, DOM nodes, and WeakMaps.
Since
0.1.0
Arguments
value(*): The value to clone.
Returns
(*): Returns the cloned value.
Example
var objects = [{ 'a': 1 }, { 'b': 2 }];var shallow = _.clone(objects);console.log(shallow[0] === objects[0]);// => true
_.cloneDeep(value)
This method is like _.clone except that it recursively clones value.
Since
1.0.0
Arguments
value(*): The value to recursively clone.
Returns
(*): Returns the deep cloned value.
Example
var objects = [{ 'a': 1 }, { 'b': 2 }];var deep = _.cloneDeep(objects);console.log(deep[0] === objects[0]);// => false
_.cloneDeepWith(value, [customizer])
This method is like _.cloneWith except that it recursively clones value.
Since
4.0.0
Arguments
value(*): The value to recursively clone.[customizer](Function): The function to customize cloning.
Returns
(*): Returns the deep cloned value.
Example
function customizer(value) {if (_.isElement(value)) {return value.cloneNode(true);}}var el = _.cloneDeepWith(document.body, customizer);console.log(el === document.body);// => falseconsole.log(el.nodeName);// => 'BODY'console.log(el.childNodes.length);// => 20
_.cloneWith(value, [customizer])
This method is like _.clone except that it accepts customizer which
is invoked to produce the cloned value. If customizer returns undefined,
cloning is handled by the method instead. The customizer is invoked with
up to four arguments; (value [, index|key, object, stack]).
Since
4.0.0
Arguments
value(*): The value to clone.[customizer](Function): The function to customize cloning.
Returns
(*): Returns the cloned value.
Example
function customizer(value) {if (_.isElement(value)) {return value.cloneNode(false);}}var el = _.cloneWith(document.body, customizer);console.log(el === document.body);// => falseconsole.log(el.nodeName);// => 'BODY'console.log(el.childNodes.length);// => 0
_.conformsTo(object, source)
Checks if object conforms to source by invoking the predicate
properties of source with the corresponding property values of object.
Note: This method is equivalent to _.conforms when source is
partially applied.
Since
4.14.0
Arguments
object(Object): The object to inspect.source(Object): The object of property predicates to conform to.
Returns
(boolean): Returns true if object conforms, else false.
Example
var object = { 'a': 1, 'b': 2 };_.conformsTo(object, { 'b': function(n) { return n > 1; } });// => true_.conformsTo(object, { 'b': function(n) { return n > 2; } });// => false
_.eq(value, other)
Performs a
SameValueZero
comparison between two values to determine if they are equivalent.
Since
4.0.0
Arguments
value(*): The value to compare.other(*): The other value to compare.
Returns
(boolean): Returns true if the values are equivalent, else false.
Example
var object = { 'a': 1 };var other = { 'a': 1 };_.eq(object, object);// => true_.eq(object, other);// => false_.eq('a', 'a');// => true_.eq('a', Object('a'));// => false_.eq(NaN, NaN);// => true
_.gt(value, other)
Checks if value is greater than other.
Since
3.9.0
Arguments
value(*): The value to compare.other(*): The other value to compare.
Returns
(boolean): Returns true if value is greater than other, else false.
Example
_.gt(3, 1);// => true_.gt(3, 3);// => false_.gt(1, 3);// => false
_.gte(value, other)
Checks if value is greater than or equal to other.
Since
3.9.0
Arguments
value(*): The value to compare.other(*): The other value to compare.
Returns
(boolean): Returns true if value is greater than or equal to other, else false.
Example
_.gte(3, 1);// => true_.gte(3, 3);// => true_.gte(1, 3);// => false
_.isArguments(value)
Checks if value is likely an arguments object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an arguments object, else false.
Example
_.isArguments(function() { return arguments; }());// => true_.isArguments([1, 2, 3]);// => false
_.isArray(value)
Checks if value is classified as an Array object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an array, else false.
Example
_.isArray([1, 2, 3]);// => true_.isArray(document.body.children);// => false_.isArray('abc');// => false_.isArray(_.noop);// => false
_.isArrayBuffer(value)
Checks if value is classified as an ArrayBuffer object.
Since
4.3.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an array buffer, else false.
Example
_.isArrayBuffer(new ArrayBuffer(2));// => true_.isArrayBuffer(new Array(2));// => false
_.isArrayLike(value)
Checks if value is array-like. A value is considered array-like if it’s
not a function and has a value.length that’s an integer greater than or
equal to 0 and less than or equal to Number.MAX_SAFE_INTEGER.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is array-like, else false.
Example
_.isArrayLike([1, 2, 3]);// => true_.isArrayLike(document.body.children);// => true_.isArrayLike('abc');// => true_.isArrayLike(_.noop);// => false
_.isArrayLikeObject(value)
This method is like _.isArrayLike except that it also checks if value
is an object.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an array-like object, else false.
Example
_.isArrayLikeObject([1, 2, 3]);// => true_.isArrayLikeObject(document.body.children);// => true_.isArrayLikeObject('abc');// => false_.isArrayLikeObject(_.noop);// => false
_.isBoolean(value)
Checks if value is classified as a boolean primitive or object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a boolean, else false.
Example
_.isBoolean(false);// => true_.isBoolean(null);// => false
_.isBuffer(value)
Checks if value is a buffer.
Since
4.3.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a buffer, else false.
Example
_.isBuffer(new Buffer(2));// => true_.isBuffer(new Uint8Array(2));// => false
_.isDate(value)
Checks if value is classified as a Date object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a date object, else false.
Example
_.isDate(new Date);// => true_.isDate('Mon April 23 2012');// => false
_.isElement(value)
Checks if value is likely a DOM element.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a DOM element, else false.
Example
_.isElement(document.body);// => true_.isElement('<body>');// => false
_.isEmpty(value)
Checks if value is an empty object, collection, map, or set.
Objects are considered empty if they have no own enumerable string keyed
properties.
Array-like values such as arguments objects, arrays, buffers, strings, or
jQuery-like collections are considered empty if they have a length of 0.
Similarly, maps and sets are considered empty if they have a size of 0.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is empty, else false.
Example
_.isEmpty(null);// => true_.isEmpty(true);// => true_.isEmpty(1);// => true_.isEmpty([1, 2, 3]);// => false_.isEmpty({ 'a': 1 });// => false
_.isEqual(value, other)
Performs a deep comparison between two values to determine if they are
equivalent.
Note: This method supports comparing arrays, array buffers, booleans,
date objects, error objects, maps, numbers, Object objects, regexes,
sets, strings, symbols, and typed arrays. Object objects are compared
by their own, not inherited, enumerable properties. Functions and DOM
nodes are compared by strict equality, i.e. ===.
Since
0.1.0
Arguments
value(*): The value to compare.other(*): The other value to compare.
Returns
(boolean): Returns true if the values are equivalent, else false.
Example
var object = { 'a': 1 };var other = { 'a': 1 };_.isEqual(object, other);// => trueobject === other;// => false
_.isEqualWith(value, other, [customizer])
This method is like _.isEqual except that it accepts customizer which
is invoked to compare values. If customizer returns undefined, comparisons
are handled by the method instead. The customizer is invoked with up to
six arguments: (objValue, othValue [, index|key, object, other, stack]).
Since
4.0.0
Arguments
value(*): The value to compare.other(*): The other value to compare.[customizer](Function): The function to customize comparisons.
Returns
(boolean): Returns true if the values are equivalent, else false.
Example
function isGreeting(value) {return /^h(?:i|ello)$/.test(value);}function customizer(objValue, othValue) {if (isGreeting(objValue) && isGreeting(othValue)) {return true;}}var array = ['hello', 'goodbye'];var other = ['hi', 'goodbye'];_.isEqualWith(array, other, customizer);// => true
_.isError(value)
Checks if value is an Error, EvalError, RangeError, ReferenceError,
SyntaxError, TypeError, or URIError object.
Since
3.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an error object, else false.
Example
_.isError(new Error);// => true_.isError(Error);// => false
_.isFinite(value)
Checks if value is a finite primitive number.
Note: This method is based on
Number.isFinite.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a finite number, else false.
Example
_.isFinite(3);// => true_.isFinite(Number.MIN_VALUE);// => true_.isFinite(Infinity);// => false_.isFinite('3');// => false
_.isFunction(value)
Checks if value is classified as a Function object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a function, else false.
Example
_.isFunction(_);// => true_.isFunction(/abc/);// => false
_.isInteger(value)
Checks if value is an integer.
Note: This method is based on
Number.isInteger.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an integer, else false.
Example
_.isInteger(3);// => true_.isInteger(Number.MIN_VALUE);// => false_.isInteger(Infinity);// => false_.isInteger('3');// => false
_.isLength(value)
Checks if value is a valid array-like length.
Note: This method is loosely based on
ToLength.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a valid length, else false.
Example
_.isLength(3);// => true_.isLength(Number.MIN_VALUE);// => false_.isLength(Infinity);// => false_.isLength('3');// => false
_.isMap(value)
Checks if value is classified as a Map object.
Since
4.3.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a map, else false.
Example
_.isMap(new Map);// => true_.isMap(new WeakMap);// => false
_.isMatch(object, source)
Performs a partial deep comparison between object and source to
determine if object contains equivalent property values.
Note: This method is equivalent to _.matches when source is
partially applied.
Partial comparisons will match empty array and empty object source
values against any array or object value, respectively. See _.isEqual
for a list of supported value comparisons.
Since
3.0.0
Arguments
object(Object): The object to inspect.source(Object): The object of property values to match.
Returns
(boolean): Returns true if object is a match, else false.
Example
var object = { 'a': 1, 'b': 2 };_.isMatch(object, { 'b': 2 });// => true_.isMatch(object, { 'b': 1 });// => false
_.isMatchWith(object, source, [customizer])
This method is like _.isMatch except that it accepts customizer which
is invoked to compare values. If customizer returns undefined, comparisons
are handled by the method instead. The customizer is invoked with five
arguments: (objValue, srcValue, index|key, object, source).
Since
4.0.0
Arguments
object(Object): The object to inspect.source(Object): The object of property values to match.[customizer](Function): The function to customize comparisons.
Returns
(boolean): Returns true if object is a match, else false.
Example
function isGreeting(value) {return /^h(?:i|ello)$/.test(value);}function customizer(objValue, srcValue) {if (isGreeting(objValue) && isGreeting(srcValue)) {return true;}}var object = { 'greeting': 'hello' };var source = { 'greeting': 'hi' };_.isMatchWith(object, source, customizer);// => true
_.isNaN(value)
Checks if value is NaN.
Note: This method is based on
Number.isNaN and is not the same as
global isNaN which returns true for
undefined and other non-number values.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is NaN, else false.
Example
_.isNaN(NaN);// => true_.isNaN(new Number(NaN));// => trueisNaN(undefined);// => true_.isNaN(undefined);// => false
_.isNative(value)
Checks if value is a pristine native function.
Note: This method can’t reliably detect native functions in the presence
of the core-js package because core-js circumvents this kind of detection.
Despite multiple requests, the core-js maintainer has made it clear: any
attempt to fix the detection will be obstructed. As a result, we’re left
with little choice but to throw an error. Unfortunately, this also affects
packages, like babel-polyfill,
which rely on core-js.
Since
3.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a native function, else false.
Example
_.isNative(Array.prototype.push);// => true_.isNative(_);// => false
_.isNil(value)
Checks if value is null or undefined.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is nullish, else false.
Example
_.isNil(null);// => true_.isNil(void 0);// => true_.isNil(NaN);// => false
_.isNull(value)
Checks if value is null.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is null, else false.
Example
_.isNull(null);// => true_.isNull(void 0);// => false
_.isNumber(value)
Checks if value is classified as a Number primitive or object.
Note: To exclude Infinity, -Infinity, and NaN, which are
classified as numbers, use the _.isFinite method.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a number, else false.
Example
_.isNumber(3);// => true_.isNumber(Number.MIN_VALUE);// => true_.isNumber(Infinity);// => true_.isNumber('3');// => false
_.isObject(value)
Checks if value is the
language type
of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is an object, else false.
Example
_.isObject({});// => true_.isObject([1, 2, 3]);// => true_.isObject(_.noop);// => true_.isObject(null);// => false
_.isObjectLike(value)
Checks if value is object-like. A value is object-like if it’s not null
and has a typeof result of “object”.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is object-like, else false.
Example
_.isObjectLike({});// => true_.isObjectLike([1, 2, 3]);// => true_.isObjectLike(_.noop);// => false_.isObjectLike(null);// => false
_.isPlainObject(value)
Checks if value is a plain object, that is, an object created by the
Object constructor or one with a [[Prototype]] of null.
Since
0.8.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a plain object, else false.
Example
function Foo() {this.a = 1;}_.isPlainObject(new Foo);// => false_.isPlainObject([1, 2, 3]);// => false_.isPlainObject({ 'x': 0, 'y': 0 });// => true_.isPlainObject(Object.create(null));// => true
_.isRegExp(value)
Checks if value is classified as a RegExp object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a regexp, else false.
Example
_.isRegExp(/abc/);// => true_.isRegExp('/abc/');// => false
_.isSafeInteger(value)
Checks if value is a safe integer. An integer is safe if it’s an IEEE-754
double precision number which isn’t the result of a rounded unsafe integer.
Note: This method is based on
Number.isSafeInteger.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a safe integer, else false.
Example
_.isSafeInteger(3);// => true_.isSafeInteger(Number.MIN_VALUE);// => false_.isSafeInteger(Infinity);// => false_.isSafeInteger('3');// => false
_.isSet(value)
Checks if value is classified as a Set object.
Since
4.3.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a set, else false.
Example
_.isSet(new Set);// => true_.isSet(new WeakSet);// => false
_.isString(value)
Checks if value is classified as a String primitive or object.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a string, else false.
Example
_.isString('abc');// => true_.isString(1);// => false
_.isSymbol(value)
Checks if value is classified as a Symbol primitive or object.
Since
4.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a symbol, else false.
Example
_.isSymbol(Symbol.iterator);// => true_.isSymbol('abc');// => false
_.isTypedArray(value)
Checks if value is classified as a typed array.
Since
3.0.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a typed array, else false.
Example
_.isTypedArray(new Uint8Array);// => true_.isTypedArray([]);// => false
_.isUndefined(value)
Checks if value is undefined.
Since
0.1.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is undefined, else false.
Example
_.isUndefined(void 0);// => true_.isUndefined(null);// => false
_.isWeakMap(value)
Checks if value is classified as a WeakMap object.
Since
4.3.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a weak map, else false.
Example
_.isWeakMap(new WeakMap);// => true_.isWeakMap(new Map);// => false
_.isWeakSet(value)
Checks if value is classified as a WeakSet object.
Since
4.3.0
Arguments
value(*): The value to check.
Returns
(boolean): Returns true if value is a weak set, else false.
Example
_.isWeakSet(new WeakSet);// => true_.isWeakSet(new Set);// => false
_.lt(value, other)
Checks if value is less than other.
Since
3.9.0
Arguments
value(*): The value to compare.other(*): The other value to compare.
Returns
(boolean): Returns true if value is less than other, else false.
Example
_.lt(1, 3);// => true_.lt(3, 3);// => false_.lt(3, 1);// => false
_.lte(value, other)
Checks if value is less than or equal to other.
Since
3.9.0
Arguments
value(*): The value to compare.other(*): The other value to compare.
Returns
(boolean): Returns true if value is less than or equal to other, else false.
Example
_.lte(1, 3);// => true_.lte(3, 3);// => true_.lte(3, 1);// => false
_.toArray(value)
Converts value to an array.
Since
0.1.0
Arguments
value(*): The value to convert.
Returns
(Array): Returns the converted array.
Example
_.toArray({ 'a': 1, 'b': 2 });// => [1, 2]_.toArray('abc');// => ['a', 'b', 'c']_.toArray(1);// => []_.toArray(null);// => []
_.toFinite(value)
Converts value to a finite number.
Since
4.12.0
Arguments
value(*): The value to convert.
Returns
(number): Returns the converted number.
Example
_.toFinite(3.2);// => 3.2_.toFinite(Number.MIN_VALUE);// => 5e-324_.toFinite(Infinity);// => 1.7976931348623157e+308_.toFinite('3.2');// => 3.2
_.toInteger(value)
Converts value to an integer.
Note: This method is loosely based on
ToInteger.
Since
4.0.0
Arguments
value(*): The value to convert.
Returns
(number): Returns the converted integer.
Example
_.toInteger(3.2);// => 3_.toInteger(Number.MIN_VALUE);// => 0_.toInteger(Infinity);// => 1.7976931348623157e+308_.toInteger('3.2');// => 3
_.toLength(value)
Converts value to an integer suitable for use as the length of an
array-like object.
Note: This method is based on
ToLength.
Since
4.0.0
Arguments
value(*): The value to convert.
Returns
(number): Returns the converted integer.
Example
_.toLength(3.2);// => 3_.toLength(Number.MIN_VALUE);// => 0_.toLength(Infinity);// => 4294967295_.toLength('3.2');// => 3
_.toNumber(value)
Converts value to a number.
Since
4.0.0
Arguments
value(*): The value to process.
Returns
(number): Returns the number.
Example
_.toNumber(3.2);// => 3.2_.toNumber(Number.MIN_VALUE);// => 5e-324_.toNumber(Infinity);// => Infinity_.toNumber('3.2');// => 3.2
_.toPlainObject(value)
Converts value to a plain object flattening inherited enumerable string
keyed properties of value to own properties of the plain object.
Since
3.0.0
Arguments
value(*): The value to convert.
Returns
(Object): Returns the converted plain object.
Example
function Foo() {this.b = 2;}Foo.prototype.c = 3;_.assign({ 'a': 1 }, new Foo);// => { 'a': 1, 'b': 2 }_.assign({ 'a': 1 }, _.toPlainObject(new Foo));// => { 'a': 1, 'b': 2, 'c': 3 }
_.toSafeInteger(value)
Converts value to a safe integer. A safe integer can be compared and
represented correctly.
Since
4.0.0
Arguments
value(*): The value to convert.
Returns
(number): Returns the converted integer.
Example
_.toSafeInteger(3.2);// => 3_.toSafeInteger(Number.MIN_VALUE);// => 0_.toSafeInteger(Infinity);// => 9007199254740991_.toSafeInteger('3.2');// => 3
_.toString(value)
Converts value to a string. An empty string is returned for null
and undefined values. The sign of -0 is preserved.
Since
4.0.0
Arguments
value(*): The value to convert.
Returns
(string): Returns the converted string.
Example
_.toString(null);// => ''_.toString(-0);// => '-0'_.toString([1, 2, 3]);// => '1,2,3'
