Lang Methods
castArray
- _.castArray(value)
- source npm package
-
Description:
Casts
value
as an array if it's not one. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
clone
- _.clone(value)
- source npm package
-
Description:
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 ofarguments
objects are cloned as plain objects. An empty object is returned for uncloneable values such as error objects, functions, DOM nodes, and WeakMaps. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
cloneDeep
- _.cloneDeep(value)
- source npm package
-
Description:
This method is like
_.clone
except that it recursively clonesvalue
. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
cloneDeepWith
- _.cloneDeepWith(value, [customizer])
- source npm package
-
Description:
This method is like
_.cloneWith
except that it recursively clonesvalue
. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
cloneWith
- _.cloneWith(value, [customizer])
- source npm package
-
Description:
This method is like
_.clone
except that it acceptscustomizer
which is invoked to produce the cloned value. Ifcustomizer
returnsundefined
, cloning is handled by the method instead. Thecustomizer
is invoked with up to four arguments; (value [, index|key, object, stack]). - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
conformsTo
- _.conformsTo(object, source)
- source npm package
-
Description:
Checks if
object
conforms tosource
by invoking the predicate properties ofsource
with the corresponding property values ofobject
.
Note: This method is equivalent to_.conforms
whensource
is partially applied. - Arguments:
object
(Object): The object to inspect.source
(Object): The object of property predicates to conform to.-
Returns:
(boolean): Returns
true
ifobject
conforms, elsefalse
. -
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
- Category: Lang Methods
- Lodash Version: 4.17.15
eq
- _.eq(value, other)
- source npm package
-
Description:
Performs a
SameValueZero
comparison between two values to determine if they are equivalent. - Arguments:
value
(*): The value to compare.other
(*): The other value to compare.-
Returns:
(boolean): Returns
true
if the values are equivalent, elsefalse
. -
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
- Category: Lang Methods
- Lodash Version: 4.17.15
gt
- _.gt(value, other)
- source npm package
-
Description:
Checks if
value
is greater thanother
. - Arguments:
value
(*): The value to compare.other
(*): The other value to compare.-
Returns:
(boolean): Returns
true
ifvalue
is greater thanother
, elsefalse
. -
Example:
_.gt(3, 1);// => true_.gt(3, 3);// => false_.gt(1, 3);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
gte
- _.gte(value, other)
- source npm package
-
Description:
Checks if
value
is greater than or equal toother
. - Arguments:
value
(*): The value to compare.other
(*): The other value to compare.-
Returns:
(boolean): Returns
true
ifvalue
is greater than or equal toother
, elsefalse
. -
Example:
_.gte(3, 1);// => true_.gte(3, 3);// => true_.gte(1, 3);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isArguments
- _.isArguments(value)
- source npm package
-
Description:
Checks if
value
is likely anarguments
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is anarguments
object, elsefalse
. -
Example:
_.isArguments(function() { return arguments; }());// => true_.isArguments([1, 2, 3]);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isArray
- _.isArray(value)
- source npm package
-
Description:
Checks if
value
is classified as anArray
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is an array, elsefalse
. -
Example:
_.isArray([1, 2, 3]);// => true_.isArray(document.body.children);// => false_.isArray('abc');// => false_.isArray(_.noop);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isArrayBuffer
- _.isArrayBuffer(value)
- source npm package
-
Description:
Checks if
value
is classified as anArrayBuffer
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is an array buffer, elsefalse
. -
Example:
_.isArrayBuffer(new ArrayBuffer(2));// => true_.isArrayBuffer(new Array(2));// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isArrayLike
- _.isArrayLike(value)
- source npm package
-
Description:
Checks if
value
is array-like. A value is considered array-like if it's not a function and has avalue.length
that's an integer greater than or equal to0
and less than or equal toNumber.MAX_SAFE_INTEGER
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is array-like, elsefalse
. -
Example:
_.isArrayLike([1, 2, 3]);// => true_.isArrayLike(document.body.children);// => true_.isArrayLike('abc');// => true_.isArrayLike(_.noop);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isArrayLikeObject
- _.isArrayLikeObject(value)
- source npm package
-
Description:
This method is like
_.isArrayLike
except that it also checks ifvalue
is an object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is an array-like object, elsefalse
. -
Example:
_.isArrayLikeObject([1, 2, 3]);// => true_.isArrayLikeObject(document.body.children);// => true_.isArrayLikeObject('abc');// => false_.isArrayLikeObject(_.noop);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isBoolean
- _.isBoolean(value)
- source npm package
-
Description:
Checks if
value
is classified as a boolean primitive or object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a boolean, elsefalse
. -
Example:
_.isBoolean(false);// => true_.isBoolean(null);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isBuffer
- _.isBuffer(value)
- source npm package
-
Description:
Checks if
value
is a buffer. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a buffer, elsefalse
. -
Example:
_.isBuffer(new Buffer(2));// => true_.isBuffer(new Uint8Array(2));// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isDate
- _.isDate(value)
- source npm package
-
Description:
Checks if
value
is classified as aDate
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a date object, elsefalse
. -
Example:
_.isDate(new Date);// => true_.isDate('Mon April 23 2012');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isElement
- _.isElement(value)
- source npm package
-
Description:
Checks if
value
is likely a DOM element. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a DOM element, elsefalse
. -
Example:
_.isElement(document.body);// => true_.isElement('<body>');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isEmpty
- _.isEmpty(value)
- source npm package
-
Description:
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 asarguments
objects, arrays, buffers, strings, or jQuery-like collections are considered empty if they have alength
of0
. Similarly, maps and sets are considered empty if they have asize
of0
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is empty, elsefalse
. -
Example:
_.isEmpty(null);// => true_.isEmpty(true);// => true_.isEmpty(1);// => true_.isEmpty([1, 2, 3]);// => false_.isEmpty({ 'a': 1 });// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isEqual
- _.isEqual(value, other)
- source npm package
-
Description:
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.===
. - Arguments:
value
(*): The value to compare.other
(*): The other value to compare.-
Returns:
(boolean): Returns
true
if the values are equivalent, elsefalse
. -
Example:
var object = { 'a': 1 };var other = { 'a': 1 };_.isEqual(object, other);// => trueobject === other;// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isEqualWith
- _.isEqualWith(value, other, [customizer])
- source npm package
-
Description:
This method is like
_.isEqual
except that it acceptscustomizer
which is invoked to compare values. Ifcustomizer
returnsundefined
, comparisons are handled by the method instead. Thecustomizer
is invoked with up to six arguments: (objValue, othValue [, index|key, object, other, stack]). - 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, elsefalse
. -
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
- Category: Lang Methods
- Lodash Version: 4.17.15
isError
- _.isError(value)
- source npm package
-
Description:
Checks if
value
is anError
,EvalError
,RangeError
,ReferenceError
,SyntaxError
,TypeError
, orURIError
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is an error object, elsefalse
. -
Example:
_.isError(new Error);// => true_.isError(Error);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isFinite
- _.isFinite(value)
- source npm package
-
Description:
Checks if
value
is a finite primitive number.
Note: This method is based onNumber.isFinite
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a finite number, elsefalse
. -
Example:
_.isFinite(3);// => true_.isFinite(Number.MIN_VALUE);// => true_.isFinite(Infinity);// => false_.isFinite('3');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isFunction
- _.isFunction(value)
- source npm package
-
Description:
Checks if
value
is classified as aFunction
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a function, elsefalse
. -
Example:
_.isFunction(_);// => true_.isFunction(/abc/);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isInteger
- _.isInteger(value)
- source npm package
-
Description:
Checks if
value
is an integer.
Note: This method is based onNumber.isInteger
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is an integer, elsefalse
. -
Example:
_.isInteger(3);// => true_.isInteger(Number.MIN_VALUE);// => false_.isInteger(Infinity);// => false_.isInteger('3');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isLength
- _.isLength(value)
- source npm package
-
Description:
Checks if
value
is a valid array-like length.
Note: This method is loosely based onToLength
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a valid length, elsefalse
. -
Example:
_.isLength(3);// => true_.isLength(Number.MIN_VALUE);// => false_.isLength(Infinity);// => false_.isLength('3');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isMap
- _.isMap(value)
- source npm package
-
Description:
Checks if
value
is classified as aMap
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a map, elsefalse
. -
Example:
_.isMap(new Map);// => true_.isMap(new WeakMap);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isMatch
- _.isMatch(object, source)
- source npm package
-
Description:
Performs a partial deep comparison between
object
andsource
to determine ifobject
contains equivalent property values.
Note: This method is equivalent to_.matches
whensource
is partially applied.
Partial comparisons will match empty array and empty objectsource
values against any array or object value, respectively. See_.isEqual
for a list of supported value comparisons. - Arguments:
object
(Object): The object to inspect.source
(Object): The object of property values to match.-
Returns:
(boolean): Returns
true
ifobject
is a match, elsefalse
. -
Example:
var object = { 'a': 1, 'b': 2 };_.isMatch(object, { 'b': 2 });// => true_.isMatch(object, { 'b': 1 });// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isMatchWith
- _.isMatchWith(object, source, [customizer])
- source npm package
-
Description:
This method is like
_.isMatch
except that it acceptscustomizer
which is invoked to compare values. Ifcustomizer
returnsundefined
, comparisons are handled by the method instead. Thecustomizer
is invoked with five arguments: (objValue, srcValue, index|key, object, source). - 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
ifobject
is a match, elsefalse
. -
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
- Category: Lang Methods
- Lodash Version: 4.17.15
isNaN
- _.isNaN(value)
- source npm package
-
Description:
Checks if
value
isNaN
.
Note: This method is based onNumber.isNaN
and is not the same as globalisNaN
which returnstrue
forundefined
and other non-number values. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
isNaN
, elsefalse
. -
Example:
_.isNaN(NaN);// => true_.isNaN(new Number(NaN));// => trueisNaN(undefined);// => true_.isNaN(undefined);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isNative
- _.isNative(value)
- source npm package
-
Description:
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. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a native function, elsefalse
. -
Example:
_.isNative(Array.prototype.push);// => true_.isNative(_);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isNil
- _.isNil(value)
- source npm package
-
Description:
Checks if
value
isnull
orundefined
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is nullish, elsefalse
. -
Example:
_.isNil(null);// => true_.isNil(void 0);// => true_.isNil(NaN);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isNull
- _.isNull(value)
- source npm package
-
Description:
Checks if
value
isnull
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
isnull
, elsefalse
. -
Example:
_.isNull(null);// => true_.isNull(void 0);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isNumber
- _.isNumber(value)
- source npm package
-
Description:
Checks if
value
is classified as aNumber
primitive or object.
Note: To excludeInfinity
,-Infinity
, andNaN
, which are classified as numbers, use the_.isFinite
method. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a number, elsefalse
. -
Example:
_.isNumber(3);// => true_.isNumber(Number.MIN_VALUE);// => true_.isNumber(Infinity);// => true_.isNumber('3');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isObject
- _.isObject(value)
- source npm package
-
Description:
Checks if
value
is the language type ofObject
. (e.g. arrays, functions, objects, regexes,new Number(0)
, andnew String('')
) - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is an object, elsefalse
. -
Example:
_.isObject({});// => true_.isObject([1, 2, 3]);// => true_.isObject(_.noop);// => true_.isObject(null);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isObjectLike
- _.isObjectLike(value)
- source npm package
-
Description:
Checks if
value
is object-like. A value is object-like if it's notnull
and has atypeof
result of "object". - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is object-like, elsefalse
. -
Example:
_.isObjectLike({});// => true_.isObjectLike([1, 2, 3]);// => true_.isObjectLike(_.noop);// => false_.isObjectLike(null);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isPlainObject
- _.isPlainObject(value)
- source npm package
-
Description:
Checks if
value
is a plain object, that is, an object created by theObject
constructor or one with a[[Prototype]]
ofnull
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a plain object, elsefalse
. -
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
- Category: Lang Methods
- Lodash Version: 4.17.15
isRegExp
- _.isRegExp(value)
- source npm package
-
Description:
Checks if
value
is classified as aRegExp
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a regexp, elsefalse
. -
Example:
_.isRegExp(/abc/);// => true_.isRegExp('/abc/');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isSafeInteger
- _.isSafeInteger(value)
- source npm package
-
Description:
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 onNumber.isSafeInteger
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a safe integer, elsefalse
. -
Example:
_.isSafeInteger(3);// => true_.isSafeInteger(Number.MIN_VALUE);// => false_.isSafeInteger(Infinity);// => false_.isSafeInteger('3');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isSet
- _.isSet(value)
- source npm package
-
Description:
Checks if
value
is classified as aSet
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a set, elsefalse
. -
Example:
_.isSet(new Set);// => true_.isSet(new WeakSet);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isString
- _.isString(value)
- source npm package
-
Description:
Checks if
value
is classified as aString
primitive or object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a string, elsefalse
. -
Example:
_.isString('abc');// => true_.isString(1);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isSymbol
- _.isSymbol(value)
- source npm package
-
Description:
Checks if
value
is classified as aSymbol
primitive or object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a symbol, elsefalse
. -
Example:
_.isSymbol(Symbol.iterator);// => true_.isSymbol('abc');// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isTypedArray
- _.isTypedArray(value)
- source npm package
-
Description:
Checks if
value
is classified as a typed array. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a typed array, elsefalse
. -
Example:
_.isTypedArray(new Uint8Array);// => true_.isTypedArray([]);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isUndefined
- _.isUndefined(value)
- source npm package
-
Description:
Checks if
value
isundefined
. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
isundefined
, elsefalse
. -
Example:
_.isUndefined(void 0);// => true_.isUndefined(null);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isWeakMap
- _.isWeakMap(value)
- source npm package
-
Description:
Checks if
value
is classified as aWeakMap
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a weak map, elsefalse
. -
Example:
_.isWeakMap(new WeakMap);// => true_.isWeakMap(new Map);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
isWeakSet
- _.isWeakSet(value)
- source npm package
-
Description:
Checks if
value
is classified as aWeakSet
object. - Arguments:
value
(*): The value to check.-
Returns:
(boolean): Returns
true
ifvalue
is a weak set, elsefalse
. -
Example:
_.isWeakSet(new WeakSet);// => true_.isWeakSet(new Set);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
lt
- _.lt(value, other)
- source npm package
-
Description:
Checks if
value
is less thanother
. - Arguments:
value
(*): The value to compare.other
(*): The other value to compare.-
Returns:
(boolean): Returns
true
ifvalue
is less thanother
, elsefalse
. -
Example:
_.lt(1, 3);// => true_.lt(3, 3);// => false_.lt(3, 1);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
lte
- _.lte(value, other)
- source npm package
-
Description:
Checks if
value
is less than or equal toother
. - Arguments:
value
(*): The value to compare.other
(*): The other value to compare.-
Returns:
(boolean): Returns
true
ifvalue
is less than or equal toother
, elsefalse
. -
Example:
_.lte(1, 3);// => true_.lte(3, 3);// => true_.lte(3, 1);// => false
- Category: Lang Methods
- Lodash Version: 4.17.15
toArray
- _.toArray(value)
- source npm package
-
Description:
Converts
value
to an array. - 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);// => []
- Category: Lang Methods
- Lodash Version: 4.17.15
toFinite
- _.toFinite(value)
- source npm package
-
Description:
Converts
value
to a finite number. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
toInteger
- _.toInteger(value)
- source npm package
-
Description:
Converts
value
to an integer.
Note: This method is loosely based onToInteger
. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
toLength
- _.toLength(value)
- source npm package
-
Description:
Converts
value
to an integer suitable for use as the length of an array-like object.
Note: This method is based onToLength
. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
toNumber
- _.toNumber(value)
- source npm package
-
Description:
Converts
value
to a number. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
toPlainObject
- _.toPlainObject(value)
- source npm package
-
Description:
Converts
value
to a plain object flattening inherited enumerable string keyed properties ofvalue
to own properties of the plain object. - 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 }
- Category: Lang Methods
- Lodash Version: 4.17.15
toSafeInteger
- _.toSafeInteger(value)
- source npm package
-
Description:
Converts
value
to a safe integer. A safe integer can be compared and represented correctly. - 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
- Category: Lang Methods
- Lodash Version: 4.17.15
toString
- _.toString(value)
- source npm package
-
Description:
Converts
value
to a string. An empty string is returned fornull
andundefined
values. The sign of-0
is preserved. - 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'
- Category: Lang Methods
- Lodash Version: 4.17.15