README.md (lodash-4.0.0) | : | README.md (lodash-4.17.21) |
---|---|---|
# <a href="https://lodash.com/">lodash</a> <span>v4.0.0</span> | # <a href="https://lodash.com/">lodash</a> <span>v4.17.21</span> | |
<!-- div class="toc-container" --> | <!-- div class="toc-container" --> | |
<!-- div --> | <!-- div --> | |
## `Array` | ## `Array` | |
* <a href="#_chunkarray-size0">`_.chunk`</a> | * <a href="#_chunkarray-size1">`_.chunk`</a> | |
* <a href="#_compactarray">`_.compact`</a> | * <a href="#_compactarray">`_.compact`</a> | |
* <a href="#_concatarray-values">`_.concat`</a> | * <a href="#_concatarray-values">`_.concat`</a> | |
* <a href="#_differencearray-values">`_.difference`</a> | * <a href="#_differencearray-values">`_.difference`</a> | |
* <a href="#_differencebyarray-values-iteratee_identity">`_.differenceBy`</a> | * <a href="#_differencebyarray-values-iteratee_identity">`_.differenceBy`</a> | |
* <a href="#_differencewitharray-values-comparator">`_.differenceWith`</a> | * <a href="#_differencewitharray-values-comparator">`_.differenceWith`</a> | |
* <a href="#_droparray-n1">`_.drop`</a> | * <a href="#_droparray-n1">`_.drop`</a> | |
* <a href="#_droprightarray-n1">`_.dropRight`</a> | * <a href="#_droprightarray-n1">`_.dropRight`</a> | |
* <a href="#_droprightwhilearray-predicate_identity">`_.dropRightWhile`</a> | * <a href="#_droprightwhilearray-predicate_identity">`_.dropRightWhile`</a> | |
* <a href="#_dropwhilearray-predicate_identity">`_.dropWhile`</a> | * <a href="#_dropwhilearray-predicate_identity">`_.dropWhile`</a> | |
* <a href="#_fillarray-value-start0-endarraylength">`_.fill`</a> | * <a href="#_fillarray-value-start0-endarraylength">`_.fill`</a> | |
* <a href="#_findindexarray-predicate_identity">`_.findIndex`</a> | * <a href="#_findindexarray-predicate_identity-fromindex0">`_.findIndex`</a> | |
* <a href="#_findlastindexarray-predicate_identity">`_.findLastIndex`</a> | * <a href="#_findlastindexarray-predicate_identity-fromindexarraylength-1">`_.fi | |
ndLastIndex`</a> | ||
* <a href="#_headarray" class="alias">`_.first` -> `head`</a> | * <a href="#_headarray" class="alias">`_.first` -> `head`</a> | |
* <a href="#_flatmaparray-iteratee_identity">`_.flatMap`</a> | ||
* <a href="#_flattenarray">`_.flatten`</a> | * <a href="#_flattenarray">`_.flatten`</a> | |
* <a href="#_flattendeeparray">`_.flattenDeep`</a> | * <a href="#_flattendeeparray">`_.flattenDeep`</a> | |
* <a href="#_flattendeptharray-depth1">`_.flattenDepth`</a> | ||
* <a href="#_frompairspairs">`_.fromPairs`</a> | * <a href="#_frompairspairs">`_.fromPairs`</a> | |
* <a href="#_headarray">`_.head`</a> | * <a href="#_headarray">`_.head`</a> | |
* <a href="#_indexofarray-value-fromindex0">`_.indexOf`</a> | * <a href="#_indexofarray-value-fromindex0">`_.indexOf`</a> | |
* <a href="#_initialarray">`_.initial`</a> | * <a href="#_initialarray">`_.initial`</a> | |
* <a href="#_intersectionarrays">`_.intersection`</a> | * <a href="#_intersectionarrays">`_.intersection`</a> | |
* <a href="#_intersectionbyarrays-iteratee_identity">`_.intersectionBy`</a> | * <a href="#_intersectionbyarrays-iteratee_identity">`_.intersectionBy`</a> | |
* <a href="#_intersectionwitharrays-comparator">`_.intersectionWith`</a> | * <a href="#_intersectionwitharrays-comparator">`_.intersectionWith`</a> | |
* <a href="#_joinarray-separator-">`_.join`</a> | * <a href="#_joinarray-separator-">`_.join`</a> | |
* <a href="#_lastarray">`_.last`</a> | * <a href="#_lastarray">`_.last`</a> | |
* <a href="#_lastindexofarray-value-fromindexarraylength-1">`_.lastIndexOf`</a> | * <a href="#_lastindexofarray-value-fromindexarraylength-1">`_.lastIndexOf`</a> | |
* <a href="#_ntharray-n0">`_.nth`</a> | ||
* <a href="#_pullarray-values">`_.pull`</a> | * <a href="#_pullarray-values">`_.pull`</a> | |
* <a href="#_pullallarray-values">`_.pullAll`</a> | * <a href="#_pullallarray-values">`_.pullAll`</a> | |
* <a href="#_pullallbyarray-values-iteratee_identity">`_.pullAllBy`</a> | * <a href="#_pullallbyarray-values-iteratee_identity">`_.pullAllBy`</a> | |
* <a href="#_pullallwitharray-values-comparator">`_.pullAllWith`</a> | ||
* <a href="#_pullatarray-indexes">`_.pullAt`</a> | * <a href="#_pullatarray-indexes">`_.pullAt`</a> | |
* <a href="#_removearray-predicate_identity">`_.remove`</a> | * <a href="#_removearray-predicate_identity">`_.remove`</a> | |
* <a href="#_reversearray">`_.reverse`</a> | ||
* <a href="#_slicearray-start0-endarraylength">`_.slice`</a> | * <a href="#_slicearray-start0-endarraylength">`_.slice`</a> | |
* <a href="#_sortedindexarray-value">`_.sortedIndex`</a> | * <a href="#_sortedindexarray-value">`_.sortedIndex`</a> | |
* <a href="#_sortedindexbyarray-value-iteratee_identity">`_.sortedIndexBy`</a> | * <a href="#_sortedindexbyarray-value-iteratee_identity">`_.sortedIndexBy`</a> | |
* <a href="#_sortedindexofarray-value">`_.sortedIndexOf`</a> | * <a href="#_sortedindexofarray-value">`_.sortedIndexOf`</a> | |
* <a href="#_sortedlastindexarray-value">`_.sortedLastIndex`</a> | * <a href="#_sortedlastindexarray-value">`_.sortedLastIndex`</a> | |
* <a href="#_sortedlastindexbyarray-value-iteratee_identity">`_.sortedLastIndexB y`</a> | * <a href="#_sortedlastindexbyarray-value-iteratee_identity">`_.sortedLastIndexB y`</a> | |
* <a href="#_sortedlastindexofarray-value">`_.sortedLastIndexOf`</a> | * <a href="#_sortedlastindexofarray-value">`_.sortedLastIndexOf`</a> | |
* <a href="#_sorteduniqarray">`_.sortedUniq`</a> | * <a href="#_sorteduniqarray">`_.sortedUniq`</a> | |
* <a href="#_sorteduniqbyarray-iteratee">`_.sortedUniqBy`</a> | * <a href="#_sorteduniqbyarray-iteratee">`_.sortedUniqBy`</a> | |
* <a href="#_tailarray">`_.tail`</a> | * <a href="#_tailarray">`_.tail`</a> | |
skipping to change at line 68 | skipping to change at line 71 | |
* <a href="#_uniqbyarray-iteratee_identity">`_.uniqBy`</a> | * <a href="#_uniqbyarray-iteratee_identity">`_.uniqBy`</a> | |
* <a href="#_uniqwitharray-comparator">`_.uniqWith`</a> | * <a href="#_uniqwitharray-comparator">`_.uniqWith`</a> | |
* <a href="#_unziparray">`_.unzip`</a> | * <a href="#_unziparray">`_.unzip`</a> | |
* <a href="#_unzipwitharray-iteratee_identity">`_.unzipWith`</a> | * <a href="#_unzipwitharray-iteratee_identity">`_.unzipWith`</a> | |
* <a href="#_withoutarray-values">`_.without`</a> | * <a href="#_withoutarray-values">`_.without`</a> | |
* <a href="#_xorarrays">`_.xor`</a> | * <a href="#_xorarrays">`_.xor`</a> | |
* <a href="#_xorbyarrays-iteratee_identity">`_.xorBy`</a> | * <a href="#_xorbyarrays-iteratee_identity">`_.xorBy`</a> | |
* <a href="#_xorwitharrays-comparator">`_.xorWith`</a> | * <a href="#_xorwitharrays-comparator">`_.xorWith`</a> | |
* <a href="#_ziparrays">`_.zip`</a> | * <a href="#_ziparrays">`_.zip`</a> | |
* <a href="#_zipobjectprops-values">`_.zipObject`</a> | * <a href="#_zipobjectprops-values">`_.zipObject`</a> | |
* <a href="#_zipobjectdeepprops-values">`_.zipObjectDeep`</a> | ||
* <a href="#_zipwitharrays-iteratee_identity">`_.zipWith`</a> | * <a href="#_zipwitharrays-iteratee_identity">`_.zipWith`</a> | |
* <a href="#_prototypereverse">`_.prototype.reverse`</a> | ||
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Collection` | ## `Collection` | |
* <a href="#_countbycollection-iteratee_identity">`_.countBy`</a> | * <a href="#_countbycollection-iteratee_identity">`_.countBy`</a> | |
* <a href="#_foreachcollection-iteratee_identity" class="alias">`_.each` -> `for Each`</a> | * <a href="#_foreachcollection-iteratee_identity" class="alias">`_.each` -> `for Each`</a> | |
* <a href="#_foreachrightcollection-iteratee_identity" class="alias">`_.eachRigh t` -> `forEachRight`</a> | * <a href="#_foreachrightcollection-iteratee_identity" class="alias">`_.eachRigh t` -> `forEachRight`</a> | |
* <a href="#_everycollection-predicate_identity">`_.every`</a> | * <a href="#_everycollection-predicate_identity">`_.every`</a> | |
* <a href="#_filtercollection-predicate_identity">`_.filter`</a> | * <a href="#_filtercollection-predicate_identity">`_.filter`</a> | |
* <a href="#_findcollection-predicate_identity">`_.find`</a> | * <a href="#_findcollection-predicate_identity-fromindex0">`_.find`</a> | |
* <a href="#_findlastcollection-predicate_identity">`_.findLast`</a> | * <a href="#_findlastcollection-predicate_identity-fromindexcollectionlength-1"> | |
`_.findLast`</a> | ||
* <a href="#_flatmapcollection-iteratee_identity">`_.flatMap`</a> | ||
* <a href="#_flatmapdeepcollection-iteratee_identity">`_.flatMapDeep`</a> | ||
* <a href="#_flatmapdepthcollection-iteratee_identity-depth1">`_.flatMapDepth`</ | ||
a> | ||
* <a href="#_foreachcollection-iteratee_identity">`_.forEach`</a> | * <a href="#_foreachcollection-iteratee_identity">`_.forEach`</a> | |
* <a href="#_foreachrightcollection-iteratee_identity">`_.forEachRight`</a> | * <a href="#_foreachrightcollection-iteratee_identity">`_.forEachRight`</a> | |
* <a href="#_groupbycollection-iteratee_identity">`_.groupBy`</a> | * <a href="#_groupbycollection-iteratee_identity">`_.groupBy`</a> | |
* <a href="#_includescollection-value-fromindex0">`_.includes`</a> | * <a href="#_includescollection-value-fromindex0">`_.includes`</a> | |
* <a href="#_invokemapcollection-path-args">`_.invokeMap`</a> | * <a href="#_invokemapcollection-path-args">`_.invokeMap`</a> | |
* <a href="#_keybycollection-iteratee_identity">`_.keyBy`</a> | * <a href="#_keybycollection-iteratee_identity">`_.keyBy`</a> | |
* <a href="#_mapcollection-iteratee_identity">`_.map`</a> | * <a href="#_mapcollection-iteratee_identity">`_.map`</a> | |
* <a href="#_orderbycollection-iteratees-_identity-orders">`_.orderBy`</a> | * <a href="#_orderbycollection-iteratees_identity-orders">`_.orderBy`</a> | |
* <a href="#_partitioncollection-predicate_identity">`_.partition`</a> | * <a href="#_partitioncollection-predicate_identity">`_.partition`</a> | |
* <a href="#_reducecollection-iteratee_identity-accumulator">`_.reduce`</a> | * <a href="#_reducecollection-iteratee_identity-accumulator">`_.reduce`</a> | |
* <a href="#_reducerightcollection-iteratee_identity-accumulator">`_.reduceRight `</a> | * <a href="#_reducerightcollection-iteratee_identity-accumulator">`_.reduceRight `</a> | |
* <a href="#_rejectcollection-predicate_identity">`_.reject`</a> | * <a href="#_rejectcollection-predicate_identity">`_.reject`</a> | |
* <a href="#_samplecollection">`_.sample`</a> | * <a href="#_samplecollection">`_.sample`</a> | |
* <a href="#_samplesizecollection-n0">`_.sampleSize`</a> | * <a href="#_samplesizecollection-n1">`_.sampleSize`</a> | |
* <a href="#_shufflecollection">`_.shuffle`</a> | * <a href="#_shufflecollection">`_.shuffle`</a> | |
* <a href="#_sizecollection">`_.size`</a> | * <a href="#_sizecollection">`_.size`</a> | |
* <a href="#_somecollection-predicate_identity">`_.some`</a> | * <a href="#_somecollection-predicate_identity">`_.some`</a> | |
* <a href="#_sortbycollection-iteratees-_identity">`_.sortBy`</a> | * <a href="#_sortbycollection-iteratees_identity">`_.sortBy`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Date` | ## `Date` | |
* <a href="#_now">`_.now`</a> | * <a href="#_now">`_.now`</a> | |
<!-- /div --> | <!-- /div --> | |
skipping to change at line 128 | skipping to change at line 134 | |
* <a href="#_bindkeyobject-key-partials">`_.bindKey`</a> | * <a href="#_bindkeyobject-key-partials">`_.bindKey`</a> | |
* <a href="#_curryfunc-arityfunclength">`_.curry`</a> | * <a href="#_curryfunc-arityfunclength">`_.curry`</a> | |
* <a href="#_curryrightfunc-arityfunclength">`_.curryRight`</a> | * <a href="#_curryrightfunc-arityfunclength">`_.curryRight`</a> | |
* <a href="#_debouncefunc-wait0-options">`_.debounce`</a> | * <a href="#_debouncefunc-wait0-options">`_.debounce`</a> | |
* <a href="#_deferfunc-args">`_.defer`</a> | * <a href="#_deferfunc-args">`_.defer`</a> | |
* <a href="#_delayfunc-wait-args">`_.delay`</a> | * <a href="#_delayfunc-wait-args">`_.delay`</a> | |
* <a href="#_flipfunc">`_.flip`</a> | * <a href="#_flipfunc">`_.flip`</a> | |
* <a href="#_memoizefunc-resolver">`_.memoize`</a> | * <a href="#_memoizefunc-resolver">`_.memoize`</a> | |
* <a href="#_negatepredicate">`_.negate`</a> | * <a href="#_negatepredicate">`_.negate`</a> | |
* <a href="#_oncefunc">`_.once`</a> | * <a href="#_oncefunc">`_.once`</a> | |
* <a href="#_overargsfunc-transforms">`_.overArgs`</a> | * <a href="#_overargsfunc-transforms_identity">`_.overArgs`</a> | |
* <a href="#_partialfunc-partials">`_.partial`</a> | * <a href="#_partialfunc-partials">`_.partial`</a> | |
* <a href="#_partialrightfunc-partials">`_.partialRight`</a> | * <a href="#_partialrightfunc-partials">`_.partialRight`</a> | |
* <a href="#_reargfunc-indexes">`_.rearg`</a> | * <a href="#_reargfunc-indexes">`_.rearg`</a> | |
* <a href="#_restfunc-startfunclength-1">`_.rest`</a> | * <a href="#_restfunc-startfunclength-1">`_.rest`</a> | |
* <a href="#_spreadfunc">`_.spread`</a> | * <a href="#_spreadfunc-start0">`_.spread`</a> | |
* <a href="#_throttlefunc-wait0-options">`_.throttle`</a> | * <a href="#_throttlefunc-wait0-options">`_.throttle`</a> | |
* <a href="#_unaryfunc">`_.unary`</a> | * <a href="#_unaryfunc">`_.unary`</a> | |
* <a href="#_wrapvalue-wrapper">`_.wrap`</a> | * <a href="#_wrapvalue-wrapperidentity">`_.wrap`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Lang` | ## `Lang` | |
* <a href="#_castarrayvalue">`_.castArray`</a> | ||
* <a href="#_clonevalue">`_.clone`</a> | * <a href="#_clonevalue">`_.clone`</a> | |
* <a href="#_clonedeepvalue">`_.cloneDeep`</a> | * <a href="#_clonedeepvalue">`_.cloneDeep`</a> | |
* <a href="#_clonedeepwithvalue-customizer">`_.cloneDeepWith`</a> | * <a href="#_clonedeepwithvalue-customizer">`_.cloneDeepWith`</a> | |
* <a href="#_clonewithvalue-customizer">`_.cloneWith`</a> | * <a href="#_clonewithvalue-customizer">`_.cloneWith`</a> | |
* <a href="#_conformstoobject-source">`_.conformsTo`</a> | ||
* <a href="#_eqvalue-other">`_.eq`</a> | * <a href="#_eqvalue-other">`_.eq`</a> | |
* <a href="#_gtvalue-other">`_.gt`</a> | * <a href="#_gtvalue-other">`_.gt`</a> | |
* <a href="#_gtevalue-other">`_.gte`</a> | * <a href="#_gtevalue-other">`_.gte`</a> | |
* <a href="#_isargumentsvalue">`_.isArguments`</a> | * <a href="#_isargumentsvalue">`_.isArguments`</a> | |
* <a href="#_isarrayvalue">`_.isArray`</a> | * <a href="#_isarrayvalue">`_.isArray`</a> | |
* <a href="#_isarraybuffervalue">`_.isArrayBuffer`</a> | ||
* <a href="#_isarraylikevalue">`_.isArrayLike`</a> | * <a href="#_isarraylikevalue">`_.isArrayLike`</a> | |
* <a href="#_isarraylikeobjectvalue">`_.isArrayLikeObject`</a> | * <a href="#_isarraylikeobjectvalue">`_.isArrayLikeObject`</a> | |
* <a href="#_isbooleanvalue">`_.isBoolean`</a> | * <a href="#_isbooleanvalue">`_.isBoolean`</a> | |
* <a href="#_isbuffervalue">`_.isBuffer`</a> | ||
* <a href="#_isdatevalue">`_.isDate`</a> | * <a href="#_isdatevalue">`_.isDate`</a> | |
* <a href="#_iselementvalue">`_.isElement`</a> | * <a href="#_iselementvalue">`_.isElement`</a> | |
* <a href="#_isemptyvalue">`_.isEmpty`</a> | * <a href="#_isemptyvalue">`_.isEmpty`</a> | |
* <a href="#_isequalvalue-other">`_.isEqual`</a> | * <a href="#_isequalvalue-other">`_.isEqual`</a> | |
* <a href="#_isequalwithvalue-other-customizer">`_.isEqualWith`</a> | * <a href="#_isequalwithvalue-other-customizer">`_.isEqualWith`</a> | |
* <a href="#_iserrorvalue">`_.isError`</a> | * <a href="#_iserrorvalue">`_.isError`</a> | |
* <a href="#_isfinitevalue">`_.isFinite`</a> | * <a href="#_isfinitevalue">`_.isFinite`</a> | |
* <a href="#_isfunctionvalue">`_.isFunction`</a> | * <a href="#_isfunctionvalue">`_.isFunction`</a> | |
* <a href="#_isintegervalue">`_.isInteger`</a> | * <a href="#_isintegervalue">`_.isInteger`</a> | |
* <a href="#_islengthvalue">`_.isLength`</a> | * <a href="#_islengthvalue">`_.isLength`</a> | |
* <a href="#_ismapvalue">`_.isMap`</a> | ||
* <a href="#_ismatchobject-source">`_.isMatch`</a> | * <a href="#_ismatchobject-source">`_.isMatch`</a> | |
* <a href="#_ismatchwithobject-source-customizer">`_.isMatchWith`</a> | * <a href="#_ismatchwithobject-source-customizer">`_.isMatchWith`</a> | |
* <a href="#_isnanvalue">`_.isNaN`</a> | * <a href="#_isnanvalue">`_.isNaN`</a> | |
* <a href="#_isnativevalue">`_.isNative`</a> | * <a href="#_isnativevalue">`_.isNative`</a> | |
* <a href="#_isnilvalue">`_.isNil`</a> | * <a href="#_isnilvalue">`_.isNil`</a> | |
* <a href="#_isnullvalue">`_.isNull`</a> | * <a href="#_isnullvalue">`_.isNull`</a> | |
* <a href="#_isnumbervalue">`_.isNumber`</a> | * <a href="#_isnumbervalue">`_.isNumber`</a> | |
* <a href="#_isobjectvalue">`_.isObject`</a> | * <a href="#_isobjectvalue">`_.isObject`</a> | |
* <a href="#_isobjectlikevalue">`_.isObjectLike`</a> | * <a href="#_isobjectlikevalue">`_.isObjectLike`</a> | |
* <a href="#_isplainobjectvalue">`_.isPlainObject`</a> | * <a href="#_isplainobjectvalue">`_.isPlainObject`</a> | |
* <a href="#_isregexpvalue">`_.isRegExp`</a> | * <a href="#_isregexpvalue">`_.isRegExp`</a> | |
* <a href="#_issafeintegervalue">`_.isSafeInteger`</a> | * <a href="#_issafeintegervalue">`_.isSafeInteger`</a> | |
* <a href="#_issetvalue">`_.isSet`</a> | ||
* <a href="#_isstringvalue">`_.isString`</a> | * <a href="#_isstringvalue">`_.isString`</a> | |
* <a href="#_issymbolvalue">`_.isSymbol`</a> | * <a href="#_issymbolvalue">`_.isSymbol`</a> | |
* <a href="#_istypedarrayvalue">`_.isTypedArray`</a> | * <a href="#_istypedarrayvalue">`_.isTypedArray`</a> | |
* <a href="#_isundefinedvalue">`_.isUndefined`</a> | * <a href="#_isundefinedvalue">`_.isUndefined`</a> | |
* <a href="#_isweakmapvalue">`_.isWeakMap`</a> | ||
* <a href="#_isweaksetvalue">`_.isWeakSet`</a> | ||
* <a href="#_ltvalue-other">`_.lt`</a> | * <a href="#_ltvalue-other">`_.lt`</a> | |
* <a href="#_ltevalue-other">`_.lte`</a> | * <a href="#_ltevalue-other">`_.lte`</a> | |
* <a href="#_toarrayvalue">`_.toArray`</a> | * <a href="#_toarrayvalue">`_.toArray`</a> | |
* <a href="#_tofinitevalue">`_.toFinite`</a> | ||
* <a href="#_tointegervalue">`_.toInteger`</a> | * <a href="#_tointegervalue">`_.toInteger`</a> | |
* <a href="#_tolengthvalue">`_.toLength`</a> | * <a href="#_tolengthvalue">`_.toLength`</a> | |
* <a href="#_tonumbervalue">`_.toNumber`</a> | * <a href="#_tonumbervalue">`_.toNumber`</a> | |
* <a href="#_toplainobjectvalue">`_.toPlainObject`</a> | * <a href="#_toplainobjectvalue">`_.toPlainObject`</a> | |
* <a href="#_tosafeintegervalue">`_.toSafeInteger`</a> | * <a href="#_tosafeintegervalue">`_.toSafeInteger`</a> | |
* <a href="#_tostringvalue">`_.toString`</a> | * <a href="#_tostringvalue">`_.toString`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Math` | ## `Math` | |
* <a href="#_addaugend-addend">`_.add`</a> | * <a href="#_addaugend-addend">`_.add`</a> | |
* <a href="#_ceilnumber-precision0">`_.ceil`</a> | * <a href="#_ceilnumber-precision0">`_.ceil`</a> | |
* <a href="#_dividedividend-divisor">`_.divide`</a> | ||
* <a href="#_floornumber-precision0">`_.floor`</a> | * <a href="#_floornumber-precision0">`_.floor`</a> | |
* <a href="#_maxarray">`_.max`</a> | * <a href="#_maxarray">`_.max`</a> | |
* <a href="#_maxbyarray-iteratee_identity">`_.maxBy`</a> | * <a href="#_maxbyarray-iteratee_identity">`_.maxBy`</a> | |
* <a href="#_meanarray">`_.mean`</a> | * <a href="#_meanarray">`_.mean`</a> | |
* <a href="#_meanbyarray-iteratee_identity">`_.meanBy`</a> | ||
* <a href="#_minarray">`_.min`</a> | * <a href="#_minarray">`_.min`</a> | |
* <a href="#_minbyarray-iteratee_identity">`_.minBy`</a> | * <a href="#_minbyarray-iteratee_identity">`_.minBy`</a> | |
* <a href="#_multiplymultiplier-multiplicand">`_.multiply`</a> | ||
* <a href="#_roundnumber-precision0">`_.round`</a> | * <a href="#_roundnumber-precision0">`_.round`</a> | |
* <a href="#_subtractminuend-subtrahend">`_.subtract`</a> | * <a href="#_subtractminuend-subtrahend">`_.subtract`</a> | |
* <a href="#_sumarray">`_.sum`</a> | * <a href="#_sumarray">`_.sum`</a> | |
* <a href="#_sumbyarray-iteratee_identity">`_.sumBy`</a> | * <a href="#_sumbyarray-iteratee_identity">`_.sumBy`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Number` | ## `Number` | |
skipping to change at line 231 | skipping to change at line 249 | |
## `Object` | ## `Object` | |
* <a href="#_assignobject-sources">`_.assign`</a> | * <a href="#_assignobject-sources">`_.assign`</a> | |
* <a href="#_assigninobject-sources">`_.assignIn`</a> | * <a href="#_assigninobject-sources">`_.assignIn`</a> | |
* <a href="#_assigninwithobject-sources-customizer">`_.assignInWith`</a> | * <a href="#_assigninwithobject-sources-customizer">`_.assignInWith`</a> | |
* <a href="#_assignwithobject-sources-customizer">`_.assignWith`</a> | * <a href="#_assignwithobject-sources-customizer">`_.assignWith`</a> | |
* <a href="#_atobject-paths">`_.at`</a> | * <a href="#_atobject-paths">`_.at`</a> | |
* <a href="#_createprototype-properties">`_.create`</a> | * <a href="#_createprototype-properties">`_.create`</a> | |
* <a href="#_defaultsobject-sources">`_.defaults`</a> | * <a href="#_defaultsobject-sources">`_.defaults`</a> | |
* <a href="#_defaultsdeepobject-sources">`_.defaultsDeep`</a> | * <a href="#_defaultsdeepobject-sources">`_.defaultsDeep`</a> | |
* <a href="#_topairsobject" class="alias">`_.entries` -> `toPairs`</a> | ||
* <a href="#_topairsinobject" class="alias">`_.entriesIn` -> `toPairsIn`</a> | ||
* <a href="#_assigninobject-sources" class="alias">`_.extend` -> `assignIn`</a> | * <a href="#_assigninobject-sources" class="alias">`_.extend` -> `assignIn`</a> | |
* <a href="#_assigninwithobject-sources-customizer" class="alias">`_.extendWith` -> `assignInWith`</a> | * <a href="#_assigninwithobject-sources-customizer" class="alias">`_.extendWith` -> `assignInWith`</a> | |
* <a href="#_findkeyobject-predicate_identity">`_.findKey`</a> | * <a href="#_findkeyobject-predicate_identity">`_.findKey`</a> | |
* <a href="#_findlastkeyobject-predicate_identity">`_.findLastKey`</a> | * <a href="#_findlastkeyobject-predicate_identity">`_.findLastKey`</a> | |
* <a href="#_forinobject-iteratee_identity">`_.forIn`</a> | * <a href="#_forinobject-iteratee_identity">`_.forIn`</a> | |
* <a href="#_forinrightobject-iteratee_identity">`_.forInRight`</a> | * <a href="#_forinrightobject-iteratee_identity">`_.forInRight`</a> | |
* <a href="#_forownobject-iteratee_identity">`_.forOwn`</a> | * <a href="#_forownobject-iteratee_identity">`_.forOwn`</a> | |
* <a href="#_forownrightobject-iteratee_identity">`_.forOwnRight`</a> | * <a href="#_forownrightobject-iteratee_identity">`_.forOwnRight`</a> | |
* <a href="#_functionsobject">`_.functions`</a> | * <a href="#_functionsobject">`_.functions`</a> | |
* <a href="#_functionsinobject">`_.functionsIn`</a> | * <a href="#_functionsinobject">`_.functionsIn`</a> | |
* <a href="#_getobject-path-defaultvalue">`_.get`</a> | * <a href="#_getobject-path-defaultvalue">`_.get`</a> | |
* <a href="#_hasobject-path">`_.has`</a> | * <a href="#_hasobject-path">`_.has`</a> | |
* <a href="#_hasinobject-path">`_.hasIn`</a> | * <a href="#_hasinobject-path">`_.hasIn`</a> | |
* <a href="#_invertobject-multival">`_.invert`</a> | * <a href="#_invertobject">`_.invert`</a> | |
* <a href="#_invertbyobject-iteratee_identity">`_.invertBy`</a> | ||
* <a href="#_invokeobject-path-args">`_.invoke`</a> | * <a href="#_invokeobject-path-args">`_.invoke`</a> | |
* <a href="#_keysobject">`_.keys`</a> | * <a href="#_keysobject">`_.keys`</a> | |
* <a href="#_keysinobject">`_.keysIn`</a> | * <a href="#_keysinobject">`_.keysIn`</a> | |
* <a href="#_mapkeysobject-iteratee_identity">`_.mapKeys`</a> | * <a href="#_mapkeysobject-iteratee_identity">`_.mapKeys`</a> | |
* <a href="#_mapvaluesobject-iteratee_identity">`_.mapValues`</a> | * <a href="#_mapvaluesobject-iteratee_identity">`_.mapValues`</a> | |
* <a href="#_mergeobject-sources">`_.merge`</a> | * <a href="#_mergeobject-sources">`_.merge`</a> | |
* <a href="#_mergewithobject-sources-customizer">`_.mergeWith`</a> | * <a href="#_mergewithobject-sources-customizer">`_.mergeWith`</a> | |
* <a href="#_omitobject-props">`_.omit`</a> | * <a href="#_omitobject-paths">`_.omit`</a> | |
* <a href="#_omitbyobject-predicate_identity">`_.omitBy`</a> | * <a href="#_omitbyobject-predicate_identity">`_.omitBy`</a> | |
* <a href="#_pickobject-props">`_.pick`</a> | * <a href="#_pickobject-paths">`_.pick`</a> | |
* <a href="#_pickbyobject-predicate_identity">`_.pickBy`</a> | * <a href="#_pickbyobject-predicate_identity">`_.pickBy`</a> | |
* <a href="#_resultobject-path-defaultvalue">`_.result`</a> | * <a href="#_resultobject-path-defaultvalue">`_.result`</a> | |
* <a href="#_setobject-path-value">`_.set`</a> | * <a href="#_setobject-path-value">`_.set`</a> | |
* <a href="#_setwithobject-path-value-customizer">`_.setWith`</a> | * <a href="#_setwithobject-path-value-customizer">`_.setWith`</a> | |
* <a href="#_topairsobject">`_.toPairs`</a> | * <a href="#_topairsobject">`_.toPairs`</a> | |
* <a href="#_topairsinobject">`_.toPairsIn`</a> | * <a href="#_topairsinobject">`_.toPairsIn`</a> | |
* <a href="#_transformobject-iteratee_identity-accumulator">`_.transform`</a> | * <a href="#_transformobject-iteratee_identity-accumulator">`_.transform`</a> | |
* <a href="#_unsetobject-path">`_.unset`</a> | * <a href="#_unsetobject-path">`_.unset`</a> | |
* <a href="#_updateobject-path-updater">`_.update`</a> | ||
* <a href="#_updatewithobject-path-updater-customizer">`_.updateWith`</a> | ||
* <a href="#_valuesobject">`_.values`</a> | * <a href="#_valuesobject">`_.values`</a> | |
* <a href="#_valuesinobject">`_.valuesIn`</a> | * <a href="#_valuesinobject">`_.valuesIn`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Seq` | ## `Seq` | |
* <a href="#_value">`_`</a> | * <a href="#_value">`_`</a> | |
* <a href="#_chainvalue">`_.chain`</a> | * <a href="#_chainvalue">`_.chain`</a> | |
* <a href="#_tapvalue-interceptor">`_.tap`</a> | * <a href="#_tapvalue-interceptor">`_.tap`</a> | |
* <a href="#_thruvalue-interceptor">`_.thru`</a> | * <a href="#_thruvalue-interceptor">`_.thru`</a> | |
* <a href="#_wrapperflatmapiteratee_identity">`_.wrapperFlatMap`</a> | ||
* <a href="#_prototypesymboliterator">`_.prototype[Symbol.iterator]`</a> | * <a href="#_prototypesymboliterator">`_.prototype[Symbol.iterator]`</a> | |
* <a href="#_prototypeatpaths">`_.prototype.at`</a> | * <a href="#_prototypeatpaths">`_.prototype.at`</a> | |
* <a href="#_prototypechain">`_.prototype.chain`</a> | * <a href="#_prototypechain">`_.prototype.chain`</a> | |
* <a href="#_prototypecommit">`_.prototype.commit`</a> | * <a href="#_prototypecommit">`_.prototype.commit`</a> | |
* <a href="#_prototypenext">`_.prototype.next`</a> | * <a href="#_prototypenext">`_.prototype.next`</a> | |
* <a href="#_prototypeplantvalue">`_.prototype.plant`</a> | * <a href="#_prototypeplantvalue">`_.prototype.plant`</a> | |
* <a href="#_prototypereverse">`_.prototype.reverse`</a> | * <a href="#_prototypereverse">`_.prototype.reverse`</a> | |
* <a href="#_prototypevalue" class="alias">`_.prototype.run` -> `value`</a> | ||
* <a href="#_prototypevalue" class="alias">`_.prototype.toJSON` -> `value`</a> | * <a href="#_prototypevalue" class="alias">`_.prototype.toJSON` -> `value`</a> | |
* <a href="#_prototypevalue">`_.prototype.value`</a> | * <a href="#_prototypevalue">`_.prototype.value`</a> | |
* <a href="#_prototypevalue" class="alias">`_.prototype.valueOf` -> `value`</a> | * <a href="#_prototypevalue" class="alias">`_.prototype.valueOf` -> `value`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `String` | ## `String` | |
* <a href="#_camelcasestring">`_.camelCase`</a> | * <a href="#_camelcasestring">`_.camelCase`</a> | |
skipping to change at line 305 | skipping to change at line 326 | |
* <a href="#_deburrstring">`_.deburr`</a> | * <a href="#_deburrstring">`_.deburr`</a> | |
* <a href="#_endswithstring-target-positionstringlength">`_.endsWith`</a> | * <a href="#_endswithstring-target-positionstringlength">`_.endsWith`</a> | |
* <a href="#_escapestring">`_.escape`</a> | * <a href="#_escapestring">`_.escape`</a> | |
* <a href="#_escaperegexpstring">`_.escapeRegExp`</a> | * <a href="#_escaperegexpstring">`_.escapeRegExp`</a> | |
* <a href="#_kebabcasestring">`_.kebabCase`</a> | * <a href="#_kebabcasestring">`_.kebabCase`</a> | |
* <a href="#_lowercasestring">`_.lowerCase`</a> | * <a href="#_lowercasestring">`_.lowerCase`</a> | |
* <a href="#_lowerfirststring">`_.lowerFirst`</a> | * <a href="#_lowerfirststring">`_.lowerFirst`</a> | |
* <a href="#_padstring-length0-chars">`_.pad`</a> | * <a href="#_padstring-length0-chars">`_.pad`</a> | |
* <a href="#_padendstring-length0-chars">`_.padEnd`</a> | * <a href="#_padendstring-length0-chars">`_.padEnd`</a> | |
* <a href="#_padstartstring-length0-chars">`_.padStart`</a> | * <a href="#_padstartstring-length0-chars">`_.padStart`</a> | |
* <a href="#_parseintstring-radix">`_.parseInt`</a> | * <a href="#_parseintstring-radix10">`_.parseInt`</a> | |
* <a href="#_repeatstring-n0">`_.repeat`</a> | * <a href="#_repeatstring-n1">`_.repeat`</a> | |
* <a href="#_replacestring-pattern-replacement">`_.replace`</a> | * <a href="#_replacestring-pattern-replacement">`_.replace`</a> | |
* <a href="#_snakecasestring">`_.snakeCase`</a> | * <a href="#_snakecasestring">`_.snakeCase`</a> | |
* <a href="#_splitstring-separator-limit">`_.split`</a> | * <a href="#_splitstring-separator-limit">`_.split`</a> | |
* <a href="#_startcasestring">`_.startCase`</a> | * <a href="#_startcasestring">`_.startCase`</a> | |
* <a href="#_startswithstring-target-position0">`_.startsWith`</a> | * <a href="#_startswithstring-target-position0">`_.startsWith`</a> | |
* <a href="#_templatestring-options">`_.template`</a> | * <a href="#_templatestring-options">`_.template`</a> | |
* <a href="#_tolowerstring">`_.toLower`</a> | * <a href="#_tolowerstring">`_.toLower`</a> | |
* <a href="#_toupperstring">`_.toUpper`</a> | * <a href="#_toupperstring">`_.toUpper`</a> | |
* <a href="#_trimstring-charswhitespace">`_.trim`</a> | * <a href="#_trimstring-charswhitespace">`_.trim`</a> | |
* <a href="#_trimendstring-charswhitespace">`_.trimEnd`</a> | * <a href="#_trimendstring-charswhitespace">`_.trimEnd`</a> | |
skipping to change at line 329 | skipping to change at line 350 | |
* <a href="#_unescapestring">`_.unescape`</a> | * <a href="#_unescapestring">`_.unescape`</a> | |
* <a href="#_uppercasestring">`_.upperCase`</a> | * <a href="#_uppercasestring">`_.upperCase`</a> | |
* <a href="#_upperfirststring">`_.upperFirst`</a> | * <a href="#_upperfirststring">`_.upperFirst`</a> | |
* <a href="#_wordsstring-pattern">`_.words`</a> | * <a href="#_wordsstring-pattern">`_.words`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Util` | ## `Util` | |
* <a href="#_attemptfunc">`_.attempt`</a> | * <a href="#_attemptfunc-args">`_.attempt`</a> | |
* <a href="#_bindallobject-methodnames">`_.bindAll`</a> | * <a href="#_bindallobject-methodnames">`_.bindAll`</a> | |
* <a href="#_condpairs">`_.cond`</a> | * <a href="#_condpairs">`_.cond`</a> | |
* <a href="#_conformssource">`_.conforms`</a> | * <a href="#_conformssource">`_.conforms`</a> | |
* <a href="#_constantvalue">`_.constant`</a> | * <a href="#_constantvalue">`_.constant`</a> | |
* <a href="#_defaulttovalue-defaultvalue">`_.defaultTo`</a> | ||
* <a href="#_flowfuncs">`_.flow`</a> | * <a href="#_flowfuncs">`_.flow`</a> | |
* <a href="#_flowrightfuncs">`_.flowRight`</a> | * <a href="#_flowrightfuncs">`_.flowRight`</a> | |
* <a href="#_identityvalue">`_.identity`</a> | * <a href="#_identityvalue">`_.identity`</a> | |
* <a href="#_iterateefunc_identity">`_.iteratee`</a> | * <a href="#_iterateefunc_identity">`_.iteratee`</a> | |
* <a href="#_matchessource">`_.matches`</a> | * <a href="#_matchessource">`_.matches`</a> | |
* <a href="#_matchespropertypath-srcvalue">`_.matchesProperty`</a> | * <a href="#_matchespropertypath-srcvalue">`_.matchesProperty`</a> | |
* <a href="#_methodpath-args">`_.method`</a> | * <a href="#_methodpath-args">`_.method`</a> | |
* <a href="#_methodofobject-args">`_.methodOf`</a> | * <a href="#_methodofobject-args">`_.methodOf`</a> | |
* <a href="#_mixinobjectlodash-source-options">`_.mixin`</a> | * <a href="#_mixinobjectlodash-source-options">`_.mixin`</a> | |
* <a href="#_noconflict">`_.noConflict`</a> | * <a href="#_noconflict">`_.noConflict`</a> | |
* <a href="#_noop">`_.noop`</a> | * <a href="#_noop">`_.noop`</a> | |
* <a href="#_nthargn0">`_.nthArg`</a> | * <a href="#_nthargn0">`_.nthArg`</a> | |
* <a href="#_overiteratees">`_.over`</a> | * <a href="#_overiteratees_identity">`_.over`</a> | |
* <a href="#_overeverypredicates">`_.overEvery`</a> | * <a href="#_overeverypredicates_identity">`_.overEvery`</a> | |
* <a href="#_oversomepredicates">`_.overSome`</a> | * <a href="#_oversomepredicates_identity">`_.overSome`</a> | |
* <a href="#_propertypath">`_.property`</a> | * <a href="#_propertypath">`_.property`</a> | |
* <a href="#_propertyofobject">`_.propertyOf`</a> | * <a href="#_propertyofobject">`_.propertyOf`</a> | |
* <a href="#_rangestart0-end-step1">`_.range`</a> | * <a href="#_rangestart0-end-step1">`_.range`</a> | |
* <a href="#_rangerightstart0-end-step1">`_.rangeRight`</a> | * <a href="#_rangerightstart0-end-step1">`_.rangeRight`</a> | |
* <a href="#_runincontextcontextroot">`_.runInContext`</a> | * <a href="#_runincontextcontextroot">`_.runInContext`</a> | |
* <a href="#_stubarray">`_.stubArray`</a> | ||
* <a href="#_stubfalse">`_.stubFalse`</a> | ||
* <a href="#_stubobject">`_.stubObject`</a> | ||
* <a href="#_stubstring">`_.stubString`</a> | ||
* <a href="#_stubtrue">`_.stubTrue`</a> | ||
* <a href="#_timesn-iteratee_identity">`_.times`</a> | * <a href="#_timesn-iteratee_identity">`_.times`</a> | |
* <a href="#_topathvalue">`_.toPath`</a> | * <a href="#_topathvalue">`_.toPath`</a> | |
* <a href="#_uniqueidprefix">`_.uniqueId`</a> | * <a href="#_uniqueidprefix">`_.uniqueId`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `Methods` | ||
* <a href="#_templatesettingsimports_">`_.templateSettings.imports._`</a> | ||
* <a href="#stringsizestring">`stringSize`</a> | ||
<!-- /div --> | ||
<!-- div --> | ||
## `Properties` | ## `Properties` | |
* <a href="#_version">`_.VERSION`</a> | * <a href="#_version">`_.VERSION`</a> | |
* <a href="#_templatesettings">`_.templateSettings`</a> | * <a href="#_templatesettings">`_.templateSettings`</a> | |
* <a href="#_templatesettingsescape">`_.templateSettings.escape`</a> | * <a href="#_templatesettingsescape">`_.templateSettings.escape`</a> | |
* <a href="#_templatesettingsevaluate">`_.templateSettings.evaluate`</a> | * <a href="#_templatesettingsevaluate">`_.templateSettings.evaluate`</a> | |
* <a href="#_templatesettingsimports">`_.templateSettings.imports`</a> | * <a href="#_templatesettingsimports">`_.templateSettings.imports`</a> | |
* <a href="#_templatesettingsinterpolate">`_.templateSettings.interpolate`</a> | * <a href="#_templatesettingsinterpolate">`_.templateSettings.interpolate`</a> | |
* <a href="#_templatesettingsvariable">`_.templateSettings.variable`</a> | * <a href="#_templatesettingsvariable">`_.templateSettings.variable`</a> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | ||
## `Methods` | ||
* <a href="#_templatesettingsimports_">`_.templateSettings.imports._`</a> | ||
<!-- /div --> | ||
<!-- /div --> | <!-- /div --> | |
<!-- div class="doc-container" --> | <!-- div class="doc-container" --> | |
<!-- div --> | <!-- div --> | |
## `“Array” Methods` | ## `“Array” Methods` | |
<!-- div --> | <!-- div --> | |
### <a id="_chunkarray-size0"></a>`_.chunk(array, [size=0])` | <h3 id="_chunkarray-size1"><code>_.chunk(array, [size=1])</code></h3> | |
<a href="#_chunkarray-size0">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L6903 "View i | |
lob/4.0.0/lodash.js#L5250 "View in source") [Ⓣ][1] [Ⓝ](https://www | n source") [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm pa | |
.npmjs.com/package/lodash.chunk "See the npm package") | ckage") [Ⓣ][1] | |
Creates an array of elements split into groups the length of `size`. | 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 | If `array` can't be split evenly, the final chunk will be the remaining | |
elements. | elements. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to process. | 1. `array` *(Array)*: The array to process. | |
2. `[size=0]` *(number)*: The length of each chunk. | 2. `[size=1]` *(number)*: The length of each chunk | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array containing chunks. | *(Array)*: Returns the new array of chunks. | |
#### Example | #### Example | |
```js | ```js | |
_.chunk(['a', 'b', 'c', 'd'], 2); | _.chunk(['a', 'b', 'c', 'd'], 2); | |
// => [['a', 'b'], ['c', 'd']] | // => [['a', 'b'], ['c', 'd']] | |
_.chunk(['a', 'b', 'c', 'd'], 3); | _.chunk(['a', 'b', 'c', 'd'], 3); | |
// => [['a', 'b', 'c'], ['d']] | // => [['a', 'b', 'c'], ['d']] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_compactarray"></a>`_.compact(array)` | <h3 id="_compactarray"><code>_.compact(array)</code></h3> | |
<a href="#_compactarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L6938 "View i | |
4.0.0/lodash.js#L5281 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | n source") [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm | |
js.com/package/lodash.compact "See the npm package") | package") [Ⓣ][1] | |
Creates an array with all falsey values removed. The values `false`, `null`, | Creates an array with all falsey values removed. The values `false`, `null`, | |
`0`, `""`, `undefined`, and `NaN` are falsey. | `0`, `""`, `undefined`, and `NaN` are falsey. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to compact. | 1. `array` *(Array)*: The array to compact. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of filtered values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
_.compact([0, 1, false, 2, '', 3]); | _.compact([0, 1, false, 2, '', 3]); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_concatarray-values"></a>`_.concat(array, [values])` | <h3 id="_concatarray-values"><code>_.concat(array, [values])</code></h3> | |
<a href="#_concatarray-values">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L6975 "View i | |
/blob/4.0.0/lodash.js#L5317 "View in source") [Ⓣ][1] [Ⓝ](https://w | n source") [Ⓝ](https://www.npmjs.com/package/lodash.concat "See the npm p | |
ww.npmjs.com/package/lodash.concat "See the npm package") | ackage") [Ⓣ][1] | |
Creates a new array concatenating `array` with any additional arrays | Creates a new array concatenating `array` with any additional arrays | |
and/or values. | and/or values. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to concatenate. | 1. `array` *(Array)*: The array to concatenate. | |
2. `[values]` *(...*)*: The values to concatenate. | 2. `[values]` *(...*)*: The values to concatenate. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new concatenated array. | *(Array)*: Returns the new concatenated array. | |
#### Example | #### Example | |
```js | ```js | |
var array = [1]; | var array = [1]; | |
var other = _.concat(array, 2, [3], [[4]]); | var other = _.concat(array, 2, [3], [[4]]); | |
console.log(other); | console.log(other); | |
// => [1, 2, 3, [4]] | // => [1, 2, 3, [4]] | |
console.log(array); | console.log(array); | |
// => [1] | // => [1] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_differencearray-values"></a>`_.difference(array, [values])` | <h3 id="_differencearray-values"><code>_.difference(array, [values])</code></h3> | |
<a href="#_differencearray-values">#</a> [Ⓢ](https://github.com/lodash/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7011 "View i | |
dash/blob/4.0.0/lodash.js#L5338 "View in source") [Ⓣ][1] [Ⓝ](https | n source") [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the n | |
://www.npmjs.com/package/lodash.difference "See the npm package") | pm package") [Ⓣ][1] | |
Creates an array of unique `array` values not included in the other | Creates an array of `array` values not included in the other given arrays | |
provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6 | using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevalu | |
.0/#sec-samevaluezero) | ezero) | |
for equality comparisons. | for equality comparisons. The order and references of result values are | |
determined by the first array. | ||
<br> | ||
<br> | ||
**Note:** Unlike `_.pullAll`, this method returns a new array. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
2. `[values]` *(...Array)*: The values to exclude. | 2. `[values]` *(...Array)*: The values to exclude. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of filtered values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
_.difference([3, 2, 1], [4, 2]); | _.difference([2, 1], [2, 3]); | |
// => [3, 1] | // => [1] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_differencebyarray-values-iteratee_identity"></a>`_.differenceBy(arra | <h3 id="_differencebyarray-values-iteratee_identity"><code>_.differenceBy(array, | |
y, [values], [iteratee=_.identity])` | [values], [iteratee=_.identity])</code></h3> | |
<a href="#_differencebyarray-values-iteratee_identity">#</a> [Ⓢ](https:// | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7043 "View i | |
github.com/lodash/lodash/blob/4.0.0/lodash.js#L5365 "View in source") [Ⓣ] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.differenceby "See the | |
[1] [Ⓝ](https://www.npmjs.com/package/lodash.differenceby "See the npm pa | npm package") [Ⓣ][1] | |
ckage") | ||
This method is like `_.difference` except that it accepts `iteratee` which | This method is like `_.difference` except that it accepts `iteratee` which | |
is invoked for each element of `array` and `values` to generate the criterion | is invoked for each element of `array` and `values` to generate the criterion | |
by which uniqueness is computed. The iteratee is invoked with one argument: (val | by which they're compared. The order and references of result values are | |
ue). | determined by the first array. The iteratee is invoked with one argument:<br> | |
*(value)*. | ||
<br> | ||
<br> | ||
**Note:** Unlike `_.pullAllBy`, this method returns a new array. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
2. `[values]` *(...Array)*: The values to exclude. | 2. `[values]` *(...Array)*: The values to exclude. | |
3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 3. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of filtered values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
_.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor); | _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); | |
// => [3.1, 1.3] | // => [1.2] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); | _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); | |
// => [{ 'x': 2 }] | // => [{ 'x': 2 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_differencewitharray-values-comparator"></a>`_.differenceWith(array, | <h3 id="_differencewitharray-values-comparator"><code>_.differenceWith(array, [v | |
[values], [comparator])` | alues], [comparator])</code></h3> | |
<a href="#_differencewitharray-values-comparator">#</a> [Ⓢ](https://githu | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7076 "View i | |
b.com/lodash/lodash/blob/4.0.0/lodash.js#L5394 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.differencewith "See t | |
Ⓝ](https://www.npmjs.com/package/lodash.differencewith "See the npm packa | he npm package") [Ⓣ][1] | |
ge") | ||
This method is like `_.difference` except that it accepts `comparator` | This method is like `_.difference` except that it accepts `comparator` | |
which is invoked to compare elements of `array` to `values`. The comparator | which is invoked to compare elements of `array` to `values`. The order and | |
is invoked with two arguments: (arrVal, othVal). | references of result values are determined by the first array. The comparator | |
is invoked with two arguments: *(arrVal, othVal)*. | ||
<br> | ||
<br> | ||
**Note:** Unlike `_.pullAllWith`, this method returns a new array. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
2. `[values]` *(...Array)*: The values to exclude. | 2. `[values]` *(...Array)*: The values to exclude. | |
3. `[comparator]` *(Function)*: The comparator invoked per element. | 3. `[comparator]` *(Function)*: The comparator invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of filtered values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | |
_.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); | _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); | |
// => [{ 'x': 2, 'y': 1 }] | // => [{ 'x': 2, 'y': 1 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_droparray-n1"></a>`_.drop(array, [n=1])` | <h3 id="_droparray-n1"><code>_.drop(array, [n=1])</code></h3> | |
<a href="#_droparray-n1">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7111 "View i | |
4.0.0/lodash.js#L5428 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | n source") [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm pac | |
js.com/package/lodash.drop "See the npm package") | kage") [Ⓣ][1] | |
Creates a slice of `array` with `n` elements dropped from the beginning. | Creates a slice of `array` with `n` elements dropped from the beginning. | |
#### Since | ||
0.5.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[n=1]` *(number)*: The number of elements to drop. | 2. `[n=1]` *(number)*: The number of elements to drop. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.drop([1, 2, 3]); | _.drop([1, 2, 3]); | |
// => [2, 3] | // => [2, 3] | |
_.drop([1, 2, 3], 2); | _.drop([1, 2, 3], 2); | |
// => [3] | // => [3] | |
_.drop([1, 2, 3], 5); | _.drop([1, 2, 3], 5); | |
// => [] | // => [] | |
_.drop([1, 2, 3], 0); | _.drop([1, 2, 3], 0); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_droprightarray-n1"></a>`_.dropRight(array, [n=1])` | <h3 id="_droprightarray-n1"><code>_.dropRight(array, [n=1])</code></h3> | |
<a href="#_droprightarray-n1">#</a> [Ⓢ](https://github.com/lodash/lodash/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7145 "View i | |
blob/4.0.0/lodash.js#L5461 "View in source") [Ⓣ][1] [Ⓝ](https://ww | n source") [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the np | |
w.npmjs.com/package/lodash.dropright "See the npm package") | m package") [Ⓣ][1] | |
Creates a slice of `array` with `n` elements dropped from the end. | Creates a slice of `array` with `n` elements dropped from the end. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[n=1]` *(number)*: The number of elements to drop. | 2. `[n=1]` *(number)*: The number of elements to drop. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.dropRight([1, 2, 3]); | _.dropRight([1, 2, 3]); | |
// => [1, 2] | // => [1, 2] | |
_.dropRight([1, 2, 3], 2); | _.dropRight([1, 2, 3], 2); | |
// => [1] | // => [1] | |
_.dropRight([1, 2, 3], 5); | _.dropRight([1, 2, 3], 5); | |
// => [] | // => [] | |
_.dropRight([1, 2, 3], 0); | _.dropRight([1, 2, 3], 0); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_droprightwhilearray-predicate_identity"></a>`_.dropRightWhile(array, | <h3 id="_droprightwhilearray-predicate_identity"><code>_.dropRightWhile(array, [ | |
[predicate=_.identity])` | predicate=_.identity])</code></h3> | |
<a href="#_droprightwhilearray-predicate_identity">#</a> [Ⓢ](https://gith | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7190 "View i | |
ub.com/lodash/lodash/blob/4.0.0/lodash.js#L5505 "View in source") [Ⓣ][1] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See t | |
[Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm pack | he npm package") [Ⓣ][1] | |
age") | ||
Creates a slice of `array` excluding elements dropped from the end. | Creates a slice of `array` excluding elements dropped from the end. | |
Elements are dropped until `predicate` returns falsey. The predicate is | Elements are dropped until `predicate` returns falsey. The predicate is | |
invoked with three arguments: (value, index, array). | invoked with three arguments: *(value, index, array)*. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': true }, | { 'user': 'barney', 'active': true }, | |
{ 'user': 'fred', 'active': false }, | { 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': false } | { 'user': 'pebbles', 'active': false } | |
]; | ]; | |
_.dropRightWhile(users, function(o) { return !o.active; }); | _.dropRightWhile(users, function(o) { return !o.active; }); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); | _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); | |
// => objects for ['barney', 'fred'] | // => objects for ['barney', 'fred'] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.dropRightWhile(users, ['active', false]); | _.dropRightWhile(users, ['active', false]); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.dropRightWhile(users, 'active'); | _.dropRightWhile(users, 'active'); | |
// => objects for ['barney', 'fred', 'pebbles'] | // => objects for ['barney', 'fred', 'pebbles'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_dropwhilearray-predicate_identity"></a>`_.dropWhile(array, [predicat | <h3 id="_dropwhilearray-predicate_identity"><code>_.dropWhile(array, [predicate= | |
e=_.identity])` | _.identity])</code></h3> | |
<a href="#_dropwhilearray-predicate_identity">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7231 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L5545 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the np | |
4C3;](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") | m package") [Ⓣ][1] | |
Creates a slice of `array` excluding elements dropped from the beginning. | Creates a slice of `array` excluding elements dropped from the beginning. | |
Elements are dropped until `predicate` returns falsey. The predicate is | Elements are dropped until `predicate` returns falsey. The predicate is | |
invoked with three arguments: (value, index, array). | invoked with three arguments: *(value, index, array)*. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': false }, | { 'user': 'barney', 'active': false }, | |
{ 'user': 'fred', 'active': false }, | { 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': true } | { 'user': 'pebbles', 'active': true } | |
]; | ]; | |
_.dropWhile(users, function(o) { return !o.active; }); | _.dropWhile(users, function(o) { return !o.active; }); | |
// => objects for ['pebbles'] | // => objects for ['pebbles'] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.dropWhile(users, { 'user': 'barney', 'active': false }); | _.dropWhile(users, { 'user': 'barney', 'active': false }); | |
// => objects for ['fred', 'pebbles'] | // => objects for ['fred', 'pebbles'] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.dropWhile(users, ['active', false]); | _.dropWhile(users, ['active', false]); | |
// => objects for ['pebbles'] | // => objects for ['pebbles'] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.dropWhile(users, 'active'); | _.dropWhile(users, 'active'); | |
// => objects for ['barney', 'fred', 'pebbles'] | // => objects for ['barney', 'fred', 'pebbles'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_fillarray-value-start0-endarraylength"></a>`_.fill(array, value, [st | <h3 id="_fillarray-value-start0-endarraylength"><code>_.fill(array, value, [star | |
art=0], [end=array.length])` | t=0], [end=array.length])</code></h3> | |
<a href="#_fillarray-value-start0-endarraylength">#</a> [Ⓢ](https://githu | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7266 "View i | |
b.com/lodash/lodash/blob/4.0.0/lodash.js#L5579 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm pac | |
Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") | kage") [Ⓣ][1] | |
Fills elements of `array` with `value` from `start` up to, but not | Fills elements of `array` with `value` from `start` up to, but not | |
including, `end`. | including, `end`. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method mutates `array`. | **Note:** This method mutates `array`. | |
#### Since | ||
3.2.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to fill. | 1. `array` *(Array)*: The array to fill. | |
2. `value` *(*)*: The value to fill `array` with. | 2. `value` *(*)*: The value to fill `array` with. | |
3. `[start=0]` *(number)*: The start position. | 3. `[start=0]` *(number)*: The start position. | |
4. `[end=array.length]` *(number)*: The end position. | 4. `[end=array.length]` *(number)*: The end position. | |
#### Returns | #### Returns | |
*(Array)*: Returns `array`. | *(Array)*: Returns `array`. | |
#### Example | #### Example | |
```js | ```js | |
var array = [1, 2, 3]; | var array = [1, 2, 3]; | |
_.fill(array, 'a'); | _.fill(array, 'a'); | |
console.log(array); | console.log(array); | |
// => ['a', 'a', 'a'] | // => ['a', 'a', 'a'] | |
_.fill(Array(3), 2); | _.fill(Array(3), 2); | |
// => [2, 2, 2] | // => [2, 2, 2] | |
_.fill([4, 6, 8, 10], '*', 1, 3); | _.fill([4, 6, 8, 10], '*', 1, 3); | |
// => [4, '*', '*', 10] | // => [4, '*', '*', 10] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_findindexarray-predicate_identity"></a>`_.findIndex(array, [predicat | <h3 id="_findindexarray-predicate_identity-fromindex0"><code>_.findIndex(array, | |
e=_.identity])` | [predicate=_.identity], [fromIndex=0])</code></h3> | |
<a href="#_findindexarray-predicate_identity">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7313 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L5624 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the np | |
4C3;](https://www.npmjs.com/package/lodash.findindex "See the npm package") | m package") [Ⓣ][1] | |
This method is like `_.find` except that it returns the index of the first | This method is like `_.find` except that it returns the index of the first | |
element `predicate` returns truthy for instead of the element itself. | element `predicate` returns truthy for instead of the element itself. | |
#### Since | ||
1.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to search. | 1. `array` *(Array)*: The array to inspect. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
iteration. | 3. `[fromIndex=0]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(number)*: Returns the index of the found element, else `-1`. | *(number)*: Returns the index of the found element, else `-1`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': false }, | { 'user': 'barney', 'active': false }, | |
{ 'user': 'fred', 'active': false }, | { 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': true } | { 'user': 'pebbles', 'active': true } | |
]; | ]; | |
_.findIndex(users, function(o) { return o.user == 'barney'; }); | _.findIndex(users, function(o) { return o.user == 'barney'; }); | |
// => 0 | // => 0 | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.findIndex(users, { 'user': 'fred', 'active': false }); | _.findIndex(users, { 'user': 'fred', 'active': false }); | |
// => 1 | // => 1 | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.findIndex(users, ['active', false]); | _.findIndex(users, ['active', false]); | |
// => 0 | // => 0 | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.findIndex(users, 'active'); | _.findIndex(users, 'active'); | |
// => 2 | // => 2 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_findlastindexarray-predicate_identity"></a>`_.findLastIndex(array, [ | <h3 id="_findlastindexarray-predicate_identity-fromindexarraylength-1"><code>_.f | |
predicate=_.identity])` | indLastIndex(array, [predicate=_.identity], [fromIndex=array.length-1])</code></ | |
<a href="#_findlastindexarray-predicate_identity">#</a> [Ⓢ](https://githu | h3> | |
b.com/lodash/lodash/blob/4.0.0/lodash.js#L5663 "View in source") [Ⓣ][1] [ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7360 "View i | |
Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm packag | n source") [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See th | |
e") | e npm package") [Ⓣ][1] | |
This method is like `_.findIndex` except that it iterates over elements | This method is like `_.findIndex` except that it iterates over elements | |
of `collection` from right to left. | of `collection` from right to left. | |
#### Since | ||
2.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to search. | 1. `array` *(Array)*: The array to inspect. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
iteration. | 3. `[fromIndex=array.length-1]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(number)*: Returns the index of the found element, else `-1`. | *(number)*: Returns the index of the found element, else `-1`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': true }, | { 'user': 'barney', 'active': true }, | |
{ 'user': 'fred', 'active': false }, | { 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': false } | { 'user': 'pebbles', 'active': false } | |
]; | ]; | |
_.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); | _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); | |
// => 2 | // => 2 | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.findLastIndex(users, { 'user': 'barney', 'active': true }); | _.findLastIndex(users, { 'user': 'barney', 'active': true }); | |
// => 0 | // => 0 | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.findLastIndex(users, ['active', false]); | _.findLastIndex(users, ['active', false]); | |
// => 2 | // => 2 | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.findLastIndex(users, 'active'); | _.findLastIndex(users, 'active'); | |
// => 0 | // => 0 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_flatmaparray-iteratee_identity"></a>`_.flatMap(array, [iteratee=_.id | <h3 id="_flattenarray"><code>_.flatten(array)</code></h3> | |
entity])` | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7389 "View i | |
<a href="#_flatmaparray-iteratee_identity">#</a> [Ⓢ](https://github.com/l | n source") [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm | |
odash/lodash/blob/4.0.0/lodash.js#L5689 "View in source") [Ⓣ][1] [Ⓝ | package") [Ⓣ][1] | |
;](https://www.npmjs.com/package/lodash.flatmap "See the npm package") | ||
Creates an array of flattened values by running each element in `array` | Flattens `array` a single level deep. | |
through `iteratee` and concating its result to the other mapped values. | ||
The iteratee is invoked with three arguments: (value, index|key, array). | #### Since | |
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to iterate over. | 1. `array` *(Array)*: The array to flatten. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per | ||
iteration. | ||
#### Returns | #### Returns | |
*(Array)*: Returns the new array. | *(Array)*: Returns the new flattened array. | |
#### Example | #### Example | |
```js | ```js | |
function duplicate(n) { | _.flatten([1, [2, [3, [4]], 5]]); | |
return [n, n]; | // => [1, 2, [3, [4]], 5] | |
} | ||
_.flatMap([1, 2], duplicate); | ||
// => [1, 1, 2, 2] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_flattenarray"></a>`_.flatten(array)` | <h3 id="_flattendeeparray"><code>_.flattenDeep(array)</code></h3> | |
<a href="#_flattenarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7408 "View i | |
4.0.0/lodash.js#L5707 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | n source") [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the | |
js.com/package/lodash.flatten "See the npm package") | npm package") [Ⓣ][1] | |
Flattens `array` a single level. | Recursively flattens `array`. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to flatten. | 1. `array` *(Array)*: The array to flatten. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new flattened array. | *(Array)*: Returns the new flattened array. | |
#### Example | #### Example | |
```js | ```js | |
_.flatten([1, [2, 3, [4]]]); | _.flattenDeep([1, [2, [3, [4]], 5]]); | |
// => [1, 2, 3, [4]] | // => [1, 2, 3, 4, 5] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_flattendeeparray"></a>`_.flattenDeep(array)` | <h3 id="_flattendeptharray-depth1"><code>_.flattenDepth(array, [depth=1])</code> | |
<a href="#_flattendeeparray">#</a> [Ⓢ](https://github.com/lodash/lodash/b | </h3> | |
lob/4.0.0/lodash.js#L5725 "View in source") [Ⓣ][1] [Ⓝ](https://www | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7433 "View i | |
.npmjs.com/package/lodash.flattendeep "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.flattendepth "See the | |
npm package") [Ⓣ][1] | ||
This method is like `_.flatten` except that it recursively flattens `array`. | Recursively flatten `array` up to `depth` times. | |
#### Since | ||
4.4.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to recursively flatten. | 1. `array` *(Array)*: The array to flatten. | |
2. `[depth=1]` *(number)*: The maximum recursion depth. | ||
#### Returns | #### Returns | |
*(Array)*: Returns the new flattened array. | *(Array)*: Returns the new flattened array. | |
#### Example | #### Example | |
```js | ```js | |
_.flattenDeep([1, [2, 3, [4]]]); | var array = [1, [2, [3, [4]], 5]]; | |
// => [1, 2, 3, 4] | ||
_.flattenDepth(array, 1); | ||
// => [1, 2, [3, [4]], 5] | ||
_.flattenDepth(array, 2); | ||
// => [1, 2, 3, [4], 5] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_frompairspairs"></a>`_.fromPairs(pairs)` | <h3 id="_frompairspairs"><code>_.fromPairs(pairs)</code></h3> | |
<a href="#_frompairspairs">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7457 "View i | |
b/4.0.0/lodash.js#L5744 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | n source") [Ⓝ](https://www.npmjs.com/package/lodash.frompairs "See the np | |
pmjs.com/package/lodash.frompairs "See the npm package") | m package") [Ⓣ][1] | |
The inverse of `_.toPairs`; this method returns an object composed | The inverse of `_.toPairs`; this method returns an object composed | |
from key-value `pairs`. | from key-value `pairs`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `pairs` *(Array)*: The key-value pairs. | 1. `pairs` *(Array)*: The key-value pairs. | |
#### Returns | #### Returns | |
*(Object)*: Returns the new object. | *(Object)*: Returns the new object. | |
#### Example | #### Example | |
```js | ```js | |
_.fromPairs([['fred', 30], ['barney', 40]]); | _.fromPairs([['a', 1], ['b', 2]]); | |
// => { 'fred': 30, 'barney': 40 } | // => { 'a': 1, 'b': 2 } | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_headarray"></a>`_.head(array)` | <h3 id="_headarray"><code>_.head(array)</code></h3> | |
<a href="#_headarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7487 "View i | |
.0/lodash.js#L5773 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.head "See the npm pac | |
com/package/lodash.head "See the npm package") | kage") [Ⓣ][1] | |
Gets the first element of `array`. | Gets the first element of `array`. | |
#### Since | ||
0.1.0 | ||
#### Aliases | #### Aliases | |
*_.first* | *_.first* | |
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
#### Returns | #### Returns | |
*(*)*: Returns the first element of `array`. | *(*)*: Returns the first element of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.head([1, 2, 3]); | _.head([1, 2, 3]); | |
// => 1 | // => 1 | |
_.head([]); | _.head([]); | |
// => undefined | // => undefined | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_indexofarray-value-fromindex0"></a>`_.indexOf(array, value, [fromInd | <h3 id="_indexofarray-value-fromindex0"><code>_.indexOf(array, value, [fromIndex | |
ex=0])` | =0])</code></h3> | |
<a href="#_indexofarray-value-fromindex0">#</a> [Ⓢ](https://github.com/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7514 "View i | |
dash/lodash/blob/4.0.0/lodash.js#L5800 "View in source") [Ⓣ][1] [Ⓝ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm | |
](https://www.npmjs.com/package/lodash.indexof "See the npm package") | package") [Ⓣ][1] | |
Gets the index at which the first occurrence of `value` is found in `array` | Gets the index at which the first occurrence of `value` is found in `array` | |
using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevalu | using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevalu | |
ezero) | ezero) | |
for equality comparisons. If `fromIndex` is negative, it's used as the offset | for equality comparisons. If `fromIndex` is negative, it's used as the | |
from the end of `array`. If `array` is sorted providing `true` for `fromIndex` | offset from the end of `array`. | |
performs a faster binary search. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to search. | 1. `array` *(Array)*: The array to inspect. | |
2. `value` *(*)*: The value to search for. | 2. `value` *(*)*: The value to search for. | |
3. `[fromIndex=0]` *(number)*: The index to search from. | 3. `[fromIndex=0]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(number)*: Returns the index of the matched value, else `-1`. | *(number)*: Returns the index of the matched value, else `-1`. | |
#### Example | #### Example | |
```js | ```js | |
_.indexOf([1, 2, 1, 2], 2); | _.indexOf([1, 2, 1, 2], 2); | |
// => 1 | // => 1 | |
// using `fromIndex` | // Search from the `fromIndex`. | |
_.indexOf([1, 2, 1, 2], 2, 2); | _.indexOf([1, 2, 1, 2], 2, 2); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_initialarray"></a>`_.initial(array)` | <h3 id="_initialarray"><code>_.initial(array)</code></h3> | |
<a href="#_initialarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7540 "View i | |
4.0.0/lodash.js#L5825 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | n source") [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm | |
js.com/package/lodash.initial "See the npm package") | package") [Ⓣ][1] | |
Gets all but the last element of `array`. | Gets all but the last element of `array`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.initial([1, 2, 3]); | _.initial([1, 2, 3]); | |
// => [1, 2] | // => [1, 2] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_intersectionarrays"></a>`_.intersection([arrays])` | <h3 id="_intersectionarrays"><code>_.intersection([arrays])</code></h3> | |
<a href="#_intersectionarrays">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7562 "View i | |
/blob/4.0.0/lodash.js#L5843 "View in source") [Ⓣ][1] [Ⓝ](https://w | n source") [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the | |
ww.npmjs.com/package/lodash.intersection "See the npm package") | npm package") [Ⓣ][1] | |
Creates an array of unique values that are included in all of the provided | Creates an array of unique values that are included in all given arrays | |
arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-s | using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevalu | |
amevaluezero) | ezero) | |
for equality comparisons. | for equality comparisons. The order and references of result values are | |
determined by the first array. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of shared values. | *(Array)*: Returns the new array of intersecting values. | |
#### Example | #### Example | |
```js | ```js | |
_.intersection([2, 1], [4, 2], [1, 2]); | _.intersection([2, 1], [2, 3]); | |
// => [2] | // => [2] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_intersectionbyarrays-iteratee_identity"></a>`_.intersectionBy([array | <h3 id="_intersectionbyarrays-iteratee_identity"><code>_.intersectionBy([arrays] | |
s], [iteratee=_.identity])` | , [iteratee=_.identity])</code></h3> | |
<a href="#_intersectionbyarrays-iteratee_identity">#</a> [Ⓢ](https://gith | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7592 "View i | |
ub.com/lodash/lodash/blob/4.0.0/lodash.js#L5870 "View in source") [Ⓣ][1] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.intersectionby "See t | |
[Ⓝ](https://www.npmjs.com/package/lodash.intersectionby "See the npm pack | he npm package") [Ⓣ][1] | |
age") | ||
This method is like `_.intersection` except that it accepts `iteratee` | This method is like `_.intersection` except that it accepts `iteratee` | |
which is invoked for each element of each `arrays` to generate the criterion | which is invoked for each element of each `arrays` to generate the criterion | |
by which uniqueness is computed. The iteratee is invoked with one argument: (val | by which they're compared. The order and references of result values are | |
ue). | determined by the first array. The iteratee is invoked with one argument:<br> | |
*(value)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of shared values. | *(Array)*: Returns the new array of intersecting values. | |
#### Example | #### Example | |
```js | ```js | |
_.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); | _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); | |
// => [2.1] | // => [2.1] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); | _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); | |
// => [{ 'x': 1 }] | // => [{ 'x': 1 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_intersectionwitharrays-comparator"></a>`_.intersectionWith([arrays], | <h3 id="_intersectionwitharrays-comparator"><code>_.intersectionWith([arrays], [ | |
[comparator])` | comparator])</code></h3> | |
<a href="#_intersectionwitharrays-comparator">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7627 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L5903 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.intersectionwith "See | |
4C3;](https://www.npmjs.com/package/lodash.intersectionwith "See the npm package | the npm package") [Ⓣ][1] | |
") | ||
This method is like `_.intersection` except that it accepts `comparator` | This method is like `_.intersection` except that it accepts `comparator` | |
which is invoked to compare elements of `arrays`. The comparator is invoked | which is invoked to compare elements of `arrays`. The order and references | |
with two arguments: (arrVal, othVal). | of result values are determined by the first array. The comparator is | |
invoked with two arguments: *(arrVal, othVal)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
2. `[comparator]` *(Function)*: The comparator invoked per element. | 2. `[comparator]` *(Function)*: The comparator invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of shared values. | *(Array)*: Returns the new array of intersecting values. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | |
var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; | var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; | |
_.intersectionWith(objects, others, _.isEqual); | _.intersectionWith(objects, others, _.isEqual); | |
// => [{ 'x': 1, 'y': 2 }] | // => [{ 'x': 1, 'y': 2 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_joinarray-separator-"></a>`_.join(array, [separator=','])` | <h3 id="_joinarray-separator-"><code>_.join(array, [separator=','])</code></h3> | |
<a href="#_joinarray-separator-">#</a> [Ⓢ](https://github.com/lodash/loda | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7655 "View i | |
sh/blob/4.0.0/lodash.js#L5931 "View in source") [Ⓣ][1] [Ⓝ](https:/ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.join "See the npm pac | |
/www.npmjs.com/package/lodash.join "See the npm package") | kage") [Ⓣ][1] | |
Converts all elements in `array` into a string separated by `separator`. | Converts all elements in `array` into a string separated by `separator`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to convert. | 1. `array` *(Array)*: The array to convert. | |
2. `[separator=',']` *(string)*: The element separator. | 2. `[separator=',']` *(string)*: The element separator. | |
#### Returns | #### Returns | |
*(string)*: Returns the joined string. | *(string)*: Returns the joined string. | |
#### Example | #### Example | |
```js | ```js | |
_.join(['a', 'b', 'c'], '~'); | _.join(['a', 'b', 'c'], '~'); | |
// => 'a~b~c' | // => 'a~b~c' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_lastarray"></a>`_.last(array)` | <h3 id="_lastarray"><code>_.last(array)</code></h3> | |
<a href="#_lastarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7673 "View i | |
.0/lodash.js#L5948 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm pac | |
com/package/lodash.last "See the npm package") | kage") [Ⓣ][1] | |
Gets the last element of `array`. | Gets the last element of `array`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
#### Returns | #### Returns | |
*(*)*: Returns the last element of `array`. | *(*)*: Returns the last element of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.last([1, 2, 3]); | _.last([1, 2, 3]); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_lastindexofarray-value-fromindexarraylength-1"></a>`_.lastIndexOf(ar | <h3 id="_lastindexofarray-value-fromindexarraylength-1"><code>_.lastIndexOf(arra | |
ray, value, [fromIndex=array.length-1])` | y, value, [fromIndex=array.length-1])</code></h3> | |
<a href="#_lastindexofarray-value-fromindexarraylength-1">#</a> [Ⓢ](https | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7699 "View i | |
://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5973 "View in source") [Ɍ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the | |
9;][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm | npm package") [Ⓣ][1] | |
package") | ||
This method is like `_.indexOf` except that it iterates over elements of | This method is like `_.indexOf` except that it iterates over elements of | |
`array` from right to left. | `array` from right to left. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to search. | 1. `array` *(Array)*: The array to inspect. | |
2. `value` *(*)*: The value to search for. | 2. `value` *(*)*: The value to search for. | |
3. `[fromIndex=array.length-1]` *(number)*: The index to search from. | 3. `[fromIndex=array.length-1]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(number)*: Returns the index of the matched value, else `-1`. | *(number)*: Returns the index of the matched value, else `-1`. | |
#### Example | #### Example | |
```js | ```js | |
_.lastIndexOf([1, 2, 1, 2], 2); | _.lastIndexOf([1, 2, 1, 2], 2); | |
// => 3 | // => 3 | |
// using `fromIndex` | // Search from the `fromIndex`. | |
_.lastIndexOf([1, 2, 1, 2], 2, 2); | _.lastIndexOf([1, 2, 1, 2], 2, 2); | |
// => 1 | // => 1 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_pullarray-values"></a>`_.pull(array, [values])` | <h3 id="_ntharray-n0"><code>_.nth(array, [n=0])</code></h3> | |
<a href="#_pullarray-values">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7735 "View i | |
lob/4.0.0/lodash.js#L6015 "View in source") [Ⓣ][1] [Ⓝ](https://www | n source") [Ⓝ](https://www.npmjs.com/package/lodash.nth "See the npm pack | |
.npmjs.com/package/lodash.pull "See the npm package") | age") [Ⓣ][1] | |
Removes all provided values from `array` using | Gets the element at index `n` of `array`. If `n` is negative, the nth | |
[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | element from the end is returned. | |
#### Since | ||
4.11.0 | ||
#### Arguments | ||
1. `array` *(Array)*: The array to query. | ||
2. `[n=0]` *(number)*: The index of the element to return. | ||
#### Returns | ||
*(*)*: Returns the nth element of `array`. | ||
#### Example | ||
```js | ||
var array = ['a', 'b', 'c', 'd']; | ||
_.nth(array, 1); | ||
// => 'b' | ||
_.nth(array, -2); | ||
// => 'c'; | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_pullarray-values"><code>_.pull(array, [values])</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7762 "View i | ||
n source") [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm pac | ||
kage") [Ⓣ][1] | ||
Removes all given values from `array` using | ||
[`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | ||
for equality comparisons. | for equality comparisons. | |
<br> | <br> | |
<br> | <br> | |
**Note:** Unlike `_.without`, this method mutates `array`. | **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` | |
to remove elements from an array by predicate. | ||
#### Since | ||
2.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to modify. | 1. `array` *(Array)*: The array to modify. | |
2. `[values]` *(...*)*: The values to remove. | 2. `[values]` *(...*)*: The values to remove. | |
#### Returns | #### Returns | |
*(Array)*: Returns `array`. | *(Array)*: Returns `array`. | |
#### Example | #### Example | |
```js | ```js | |
var array = [1, 2, 3, 1, 2, 3]; | var array = ['a', 'b', 'c', 'a', 'b', 'c']; | |
_.pull(array, 2, 3); | _.pull(array, 'a', 'c'); | |
console.log(array); | console.log(array); | |
// => [1, 1] | // => ['b', 'b'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_pullallarray-values"></a>`_.pullAll(array, values)` | <h3 id="_pullallarray-values"><code>_.pullAll(array, values)</code></h3> | |
<a href="#_pullallarray-values">#</a> [Ⓢ](https://github.com/lodash/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7784 "View i | |
h/blob/4.0.0/lodash.js#L6036 "View in source") [Ⓣ][1] [Ⓝ](https:// | n source") [Ⓝ](https://www.npmjs.com/package/lodash.pullall "See the npm | |
www.npmjs.com/package/lodash.pullall "See the npm package") | package") [Ⓣ][1] | |
This method is like `_.pull` except that it accepts an array of values to remove . | This method is like `_.pull` except that it accepts an array of values to remove . | |
<br> | <br> | |
<br> | <br> | |
**Note:** Unlike `_.difference`, this method mutates `array`. | **Note:** Unlike `_.difference`, this method mutates `array`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to modify. | 1. `array` *(Array)*: The array to modify. | |
2. `values` *(Array)*: The values to remove. | 2. `values` *(Array)*: The values to remove. | |
#### Returns | #### Returns | |
*(Array)*: Returns `array`. | *(Array)*: Returns `array`. | |
#### Example | #### Example | |
```js | ```js | |
var array = [1, 2, 3, 1, 2, 3]; | var array = ['a', 'b', 'c', 'a', 'b', 'c']; | |
_.pull(array, [2, 3]); | _.pullAll(array, ['a', 'c']); | |
console.log(array); | console.log(array); | |
// => [1, 1] | // => ['b', 'b'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_pullallbyarray-values-iteratee_identity"></a>`_.pullAllBy(array, val | <h3 id="_pullallbyarray-values-iteratee_identity"><code>_.pullAllBy(array, value | |
ues, [iteratee=_.identity])` | s, [iteratee=_.identity])</code></h3> | |
<a href="#_pullallbyarray-values-iteratee_identity">#</a> [Ⓢ](https://git | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7813 "View i | |
hub.com/lodash/lodash/blob/4.0.0/lodash.js#L6064 "View in source") [Ⓣ][1] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.pullallby "See the np | |
[Ⓝ](https://www.npmjs.com/package/lodash.pullallby "See the npm package" | m package") [Ⓣ][1] | |
) | ||
This method is like `_.pullAll` except that it accepts `iteratee` which is | This method is like `_.pullAll` except that it accepts `iteratee` which is | |
invoked for each element of `array` and `values` to to generate the criterion | invoked for each element of `array` and `values` to generate the criterion | |
by which uniqueness is computed. The iteratee is invoked with one argument: (val | by which they're compared. The iteratee is invoked with one argument: *(value)*. | |
ue). | ||
<br> | <br> | |
<br> | <br> | |
**Note:** Unlike `_.differenceBy`, this method mutates `array`. | **Note:** Unlike `_.differenceBy`, this method mutates `array`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to modify. | 1. `array` *(Array)*: The array to modify. | |
2. `values` *(Array)*: The values to remove. | 2. `values` *(Array)*: The values to remove. | |
3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 3. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns `array`. | *(Array)*: Returns `array`. | |
#### Example | #### Example | |
```js | ```js | |
var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; | var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; | |
_.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); | _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); | |
console.log(array); | console.log(array); | |
// => [{ 'x': 2 }] | // => [{ 'x': 2 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_pullatarray-indexes"></a>`_.pullAt(array, [indexes])` | <h3 id="_pullallwitharray-values-comparator"><code>_.pullAllWith(array, values, | |
<a href="#_pullatarray-indexes">#</a> [Ⓢ](https://github.com/lodash/lodas | [comparator])</code></h3> | |
h/blob/4.0.0/lodash.js#L6094 "View in source") [Ⓣ][1] [Ⓝ](https:// | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7842 "View i | |
www.npmjs.com/package/lodash.pullat "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.pullallwith "See the | |
npm package") [Ⓣ][1] | ||
This method is like `_.pullAll` except that it accepts `comparator` which | ||
is invoked to compare elements of `array` to `values`. The comparator is | ||
invoked with two arguments: *(arrVal, othVal)*. | ||
<br> | ||
<br> | ||
**Note:** Unlike `_.differenceWith`, this method mutates `array`. | ||
#### Since | ||
4.6.0 | ||
#### Arguments | ||
1. `array` *(Array)*: The array to modify. | ||
2. `values` *(Array)*: The values to remove. | ||
3. `[comparator]` *(Function)*: The comparator invoked per element. | ||
#### Returns | ||
*(Array)*: Returns `array`. | ||
#### Example | ||
```js | ||
var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; | ||
_.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); | ||
console.log(array); | ||
// => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_pullatarray-indexes"><code>_.pullAt(array, [indexes])</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7872 "View i | ||
n source") [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm p | ||
ackage") [Ⓣ][1] | ||
Removes elements from `array` corresponding to `indexes` and returns an | Removes elements from `array` corresponding to `indexes` and returns an | |
array of removed elements. | array of removed elements. | |
<br> | <br> | |
<br> | <br> | |
**Note:** Unlike `_.at`, this method mutates `array`. | **Note:** Unlike `_.at`, this method mutates `array`. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to modify. | 1. `array` *(Array)*: The array to modify. | |
2. `[indexes]` *(...(number|number[])*: The indexes of elements to remov e, specified individually or in arrays. | 2. `[indexes]` *(...(number|number[]))*: The indexes of elements to remo ve. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of removed elements. | *(Array)*: Returns the new array of removed elements. | |
#### Example | #### Example | |
```js | ```js | |
var array = [5, 10, 15, 20]; | var array = ['a', 'b', 'c', 'd']; | |
var evens = _.pullAt(array, 1, 3); | var pulled = _.pullAt(array, [1, 3]); | |
console.log(array); | console.log(array); | |
// => [5, 15] | // => ['a', 'c'] | |
console.log(evens); | console.log(pulled); | |
// => [10, 20] | // => ['b', 'd'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_removearray-predicate_identity"></a>`_.remove(array, [predicate=_.id | <h3 id="_removearray-predicate_identity"><code>_.remove(array, [predicate=_.iden | |
entity])` | tity])</code></h3> | |
<a href="#_removearray-predicate_identity">#</a> [Ⓢ](https://github.com/l | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7911 "View i | |
odash/lodash/blob/4.0.0/lodash.js#L6128 "View in source") [Ⓣ][1] [Ⓝ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm p | |
;](https://www.npmjs.com/package/lodash.remove "See the npm package") | ackage") [Ⓣ][1] | |
Removes all elements from `array` that `predicate` returns truthy for | Removes all elements from `array` that `predicate` returns truthy for | |
and returns an array of the removed elements. The predicate is invoked with | and returns an array of the removed elements. The predicate is invoked | |
three arguments: (value, index, array). | with three arguments: *(value, index, array)*. | |
<br> | <br> | |
<br> | <br> | |
**Note:** Unlike `_.filter`, this method mutates `array`. | **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` | |
to pull elements from an array by value. | ||
#### Since | ||
2.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to modify. | 1. `array` *(Array)*: The array to modify. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of removed elements. | *(Array)*: Returns the new array of removed elements. | |
#### Example | #### Example | |
```js | ```js | |
var array = [1, 2, 3, 4]; | var array = [1, 2, 3, 4]; | |
var evens = _.remove(array, function(n) { | var evens = _.remove(array, function(n) { | |
return n % 2 == 0; | return n % 2 == 0; | |
}); | }); | |
console.log(array); | console.log(array); | |
// => [1, 3] | // => [1, 3] | |
console.log(evens); | console.log(evens); | |
// => [2, 4] | // => [2, 4] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_reversearray"><code>_.reverse(array)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7955 "View i | ||
n source") [Ⓝ](https://www.npmjs.com/package/lodash.reverse "See the npm | ||
package") [Ⓣ][1] | ||
Reverses `array` so that the first element becomes the last, the second | ||
element becomes the second to last, and so on. | ||
<br> | ||
<br> | ||
**Note:** This method mutates `array` and is based on | ||
[`Array#reverse`](https://mdn.io/Array/reverse). | ||
#### Since | ||
4.0.0 | ||
#### Arguments | ||
1. `array` *(Array)*: The array to modify. | ||
#### Returns | ||
*(Array)*: Returns `array`. | ||
#### Example | ||
```js | ||
var array = [1, 2, 3]; | ||
_.reverse(array); | ||
// => [3, 2, 1] | ||
console.log(array); | ||
// => [3, 2, 1] | ||
``` | ||
--- | ||
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_slicearray-start0-endarraylength"></a>`_.slice(array, [start=0], [en | <h3 id="_slicearray-start0-endarraylength"><code>_.slice(array, [start=0], [end= | |
d=array.length])` | array.length])</code></h3> | |
<a href="#_slicearray-start0-endarraylength">#</a> [Ⓢ](https://github.com | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L7975 "View i | |
/lodash/lodash/blob/4.0.0/lodash.js#L6187 "View in source") [Ⓣ][1] [$ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm pa | |
C3;](https://www.npmjs.com/package/lodash.slice "See the npm package") | ckage") [Ⓣ][1] | |
Creates a slice of `array` from `start` up to, but not including, `end`. | Creates a slice of `array` from `start` up to, but not including, `end`. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is used instead of [`Array#slice`](https://mdn.io/Array/sl | **Note:** This method is used instead of | |
ice) | [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are | |
to ensure dense arrays are returned. | returned. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to slice. | 1. `array` *(Array)*: The array to slice. | |
2. `[start=0]` *(number)*: The start position. | 2. `[start=0]` *(number)*: The start position. | |
3. `[end=array.length]` *(number)*: The end position. | 3. `[end=array.length]` *(number)*: The end position. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortedindexarray-value"></a>`_.sortedIndex(array, value)` | <h3 id="_sortedindexarray-value"><code>_.sortedIndex(array, value)</code></h3> | |
<a href="#_sortedindexarray-value">#</a> [Ⓢ](https://github.com/lodash/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8008 "View i | |
dash/blob/4.0.0/lodash.js#L6221 "View in source") [Ⓣ][1] [Ⓝ](https | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the | |
://www.npmjs.com/package/lodash.sortedindex "See the npm package") | npm package") [Ⓣ][1] | |
Uses a binary search to determine the lowest index at which `value` should | Uses a binary search to determine the lowest index at which `value` | |
be inserted into `array` in order to maintain its sort order. | should be inserted into `array` in order to maintain its sort order. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The sorted array to inspect. | 1. `array` *(Array)*: The sorted array to inspect. | |
2. `value` *(*)*: The value to evaluate. | 2. `value` *(*)*: The value to evaluate. | |
#### Returns | #### Returns | |
*(number)*: Returns the index at which `value` should be inserted into `array`. | *(number)*: Returns the index at which `value` should be inserted into `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.sortedIndex([30, 50], 40); | _.sortedIndex([30, 50], 40); | |
// => 1 | // => 1 | |
_.sortedIndex([4, 5], 4); | ||
// => 0 | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortedindexbyarray-value-iteratee_identity"></a>`_.sortedIndexBy(arr | <h3 id="_sortedindexbyarray-value-iteratee_identity"><code>_.sortedIndexBy(array | |
ay, value, [iteratee=_.identity])` | , value, [iteratee=_.identity])</code></h3> | |
<a href="#_sortedindexbyarray-value-iteratee_identity">#</a> [Ⓢ](https:// | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8037 "View i | |
github.com/lodash/lodash/blob/4.0.0/lodash.js#L6248 "View in source") [Ⓣ] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexby "See th | |
[1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexby "See the npm p | e npm package") [Ⓣ][1] | |
ackage") | ||
This method is like `_.sortedIndex` except that it accepts `iteratee` | This method is like `_.sortedIndex` except that it accepts `iteratee` | |
which is invoked for `value` and each element of `array` to compute their | which is invoked for `value` and each element of `array` to compute their | |
sort ranking. The iteratee is invoked with one argument: (value). | sort ranking. The iteratee is invoked with one argument: *(value)*. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The sorted array to inspect. | 1. `array` *(Array)*: The sorted array to inspect. | |
2. `value` *(*)*: The value to evaluate. | 2. `value` *(*)*: The value to evaluate. | |
3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 3. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(number)*: Returns the index at which `value` should be inserted into `array`. | *(number)*: Returns the index at which `value` should be inserted into `array`. | |
#### Example | #### Example | |
```js | ```js | |
var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 }; | var objects = [{ 'x': 4 }, { 'x': 5 }]; | |
_.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); | _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); | |
// => 1 | // => 0 | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); | _.sortedIndexBy(objects, { 'x': 4 }, 'x'); | |
// => 0 | // => 0 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortedindexofarray-value"></a>`_.sortedIndexOf(array, value)` | <h3 id="_sortedindexofarray-value"><code>_.sortedIndexOf(array, value)</code></h | |
<a href="#_sortedindexofarray-value">#</a> [Ⓢ](https://github.com/lodash/ | 3> | |
lodash/blob/4.0.0/lodash.js#L6267 "View in source") [Ⓣ][1] [Ⓝ](htt | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8057 "View i | |
ps://www.npmjs.com/package/lodash.sortedindexof "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexof "See th | |
e npm package") [Ⓣ][1] | ||
This method is like `_.indexOf` except that it performs a binary | This method is like `_.indexOf` except that it performs a binary | |
search on a sorted `array`. | search on a sorted `array`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to search. | 1. `array` *(Array)*: The array to inspect. | |
2. `value` *(*)*: The value to search for. | 2. `value` *(*)*: The value to search for. | |
#### Returns | #### Returns | |
*(number)*: Returns the index of the matched value, else `-1`. | *(number)*: Returns the index of the matched value, else `-1`. | |
#### Example | #### Example | |
```js | ```js | |
_.sortedIndexOf([1, 1, 2, 2], 2); | _.sortedIndexOf([4, 5, 5, 5, 6], 5); | |
// => 2 | // => 1 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortedlastindexarray-value"></a>`_.sortedLastIndex(array, value)` | <h3 id="_sortedlastindexarray-value"><code>_.sortedLastIndex(array, value)</code | |
<a href="#_sortedlastindexarray-value">#</a> [Ⓢ](https://github.com/lodas | ></h3> | |
h/lodash/blob/4.0.0/lodash.js#L6294 "View in source") [Ⓣ][1] [Ⓝ](h | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8086 "View i | |
ttps://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See | |
the npm package") [Ⓣ][1] | ||
This method is like `_.sortedIndex` except that it returns the highest | This method is like `_.sortedIndex` except that it returns the highest | |
index at which `value` should be inserted into `array` in order to | index at which `value` should be inserted into `array` in order to | |
maintain its sort order. | maintain its sort order. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The sorted array to inspect. | 1. `array` *(Array)*: The sorted array to inspect. | |
2. `value` *(*)*: The value to evaluate. | 2. `value` *(*)*: The value to evaluate. | |
#### Returns | #### Returns | |
*(number)*: Returns the index at which `value` should be inserted into `array`. | *(number)*: Returns the index at which `value` should be inserted into `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.sortedLastIndex([4, 5], 4); | _.sortedLastIndex([4, 5, 5, 5, 6], 5); | |
// => 1 | // => 4 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortedlastindexbyarray-value-iteratee_identity"></a>`_.sortedLastInd | <h3 id="_sortedlastindexbyarray-value-iteratee_identity"><code>_.sortedLastIndex | |
exBy(array, value, [iteratee=_.identity])` | By(array, value, [iteratee=_.identity])</code></h3> | |
<a href="#_sortedlastindexbyarray-value-iteratee_identity">#</a> [Ⓢ](http | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8115 "View i | |
s://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6316 "View in source") [$ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexby "Se | |
C9;][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexby "See t | e the npm package") [Ⓣ][1] | |
he npm package") | ||
This method is like `_.sortedLastIndex` except that it accepts `iteratee` | This method is like `_.sortedLastIndex` except that it accepts `iteratee` | |
which is invoked for `value` and each element of `array` to compute their | which is invoked for `value` and each element of `array` to compute their | |
sort ranking. The iteratee is invoked with one argument: (value). | sort ranking. The iteratee is invoked with one argument: *(value)*. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The sorted array to inspect. | 1. `array` *(Array)*: The sorted array to inspect. | |
2. `value` *(*)*: The value to evaluate. | 2. `value` *(*)*: The value to evaluate. | |
3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 3. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(number)*: Returns the index at which `value` should be inserted into `array`. | *(number)*: Returns the index at which `value` should be inserted into `array`. | |
#### Example | #### Example | |
```js | ```js | |
// using the `_.property` iteratee shorthand | var objects = [{ 'x': 4 }, { 'x': 5 }]; | |
_.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); | ||
_.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); | ||
// => 1 | ||
// The `_.property` iteratee shorthand. | ||
_.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); | ||
// => 1 | // => 1 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortedlastindexofarray-value"></a>`_.sortedLastIndexOf(array, value) | <h3 id="_sortedlastindexofarray-value"><code>_.sortedLastIndexOf(array, value)</ | |
` | code></h3> | |
<a href="#_sortedlastindexofarray-value">#</a> [Ⓢ](https://github.com/lod | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8135 "View i | |
ash/lodash/blob/4.0.0/lodash.js#L6335 "View in source") [Ⓣ][1] [Ⓝ] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexof "Se | |
(https://www.npmjs.com/package/lodash.sortedlastindexof "See the npm package") | e the npm package") [Ⓣ][1] | |
This method is like `_.lastIndexOf` except that it performs a binary | This method is like `_.lastIndexOf` except that it performs a binary | |
search on a sorted `array`. | search on a sorted `array`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to search. | 1. `array` *(Array)*: The array to inspect. | |
2. `value` *(*)*: The value to search for. | 2. `value` *(*)*: The value to search for. | |
#### Returns | #### Returns | |
*(number)*: Returns the index of the matched value, else `-1`. | *(number)*: Returns the index of the matched value, else `-1`. | |
#### Example | #### Example | |
```js | ```js | |
_.sortedLastIndexOf([1, 1, 2, 2], 2); | _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sorteduniqarray"></a>`_.sortedUniq(array)` | <h3 id="_sorteduniqarray"><code>_.sortedUniq(array)</code></h3> | |
<a href="#_sorteduniqarray">#</a> [Ⓢ](https://github.com/lodash/lodash/bl | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8161 "View i | |
ob/4.0.0/lodash.js#L6360 "View in source") [Ⓣ][1] [Ⓝ](https://www. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sorteduniq "See the n | |
npmjs.com/package/lodash.sorteduniq "See the npm package") | pm package") [Ⓣ][1] | |
This method is like `_.uniq` except that it's designed and optimized | This method is like `_.uniq` except that it's designed and optimized | |
for sorted arrays. | for sorted arrays. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new duplicate free array. | *(Array)*: Returns the new duplicate free array. | |
#### Example | #### Example | |
```js | ```js | |
_.sortedUniq([1, 1, 2]); | _.sortedUniq([1, 1, 2]); | |
// => [1, 2] | // => [1, 2] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sorteduniqbyarray-iteratee"></a>`_.sortedUniqBy(array, [iteratee])` | <h3 id="_sorteduniqbyarray-iteratee"><code>_.sortedUniqBy(array, [iteratee])</co | |
<a href="#_sorteduniqbyarray-iteratee">#</a> [Ⓢ](https://github.com/lodas | de></h3> | |
h/lodash/blob/4.0.0/lodash.js#L6381 "View in source") [Ⓣ][1] [Ⓝ](h | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8183 "View i | |
ttps://www.npmjs.com/package/lodash.sorteduniqby "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sorteduniqby "See the | |
npm package") [Ⓣ][1] | ||
This method is like `_.uniqBy` except that it's designed and optimized | This method is like `_.uniqBy` except that it's designed and optimized | |
for sorted arrays. | for sorted arrays. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
2. `[iteratee]` *(Function)*: The iteratee invoked per element. | 2. `[iteratee]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new duplicate free array. | *(Array)*: Returns the new duplicate free array. | |
#### Example | #### Example | |
```js | ```js | |
_.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); | _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); | |
// => [1.1, 2.2] | // => [1.1, 2.3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_tailarray"></a>`_.tail(array)` | <h3 id="_tailarray"><code>_.tail(array)</code></h3> | |
<a href="#_tailarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8203 "View i | |
.0/lodash.js#L6400 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.tail "See the npm pac | |
com/package/lodash.tail "See the npm package") | kage") [Ⓣ][1] | |
Gets all but the first element of `array`. | Gets all but the first element of `array`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.tail([1, 2, 3]); | _.tail([1, 2, 3]); | |
// => [2, 3] | // => [2, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_takearray-n1"></a>`_.take(array, [n=1])` | <h3 id="_takearray-n1"><code>_.take(array, [n=1])</code></h3> | |
<a href="#_takearray-n1">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8233 "View i | |
4.0.0/lodash.js#L6428 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | n source") [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm pac | |
js.com/package/lodash.take "See the npm package") | kage") [Ⓣ][1] | |
Creates a slice of `array` with `n` elements taken from the beginning. | Creates a slice of `array` with `n` elements taken from the beginning. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[n=1]` *(number)*: The number of elements to take. | 2. `[n=1]` *(number)*: The number of elements to take. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.take([1, 2, 3]); | _.take([1, 2, 3]); | |
// => [1] | // => [1] | |
_.take([1, 2, 3], 2); | _.take([1, 2, 3], 2); | |
// => [1, 2] | // => [1, 2] | |
_.take([1, 2, 3], 5); | _.take([1, 2, 3], 5); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
_.take([1, 2, 3], 0); | _.take([1, 2, 3], 0); | |
// => [] | // => [] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_takerightarray-n1"></a>`_.takeRight(array, [n=1])` | <h3 id="_takerightarray-n1"><code>_.takeRight(array, [n=1])</code></h3> | |
<a href="#_takerightarray-n1">#</a> [Ⓢ](https://github.com/lodash/lodash/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8266 "View i | |
blob/4.0.0/lodash.js#L6460 "View in source") [Ⓣ][1] [Ⓝ](https://ww | n source") [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the np | |
w.npmjs.com/package/lodash.takeright "See the npm package") | m package") [Ⓣ][1] | |
Creates a slice of `array` with `n` elements taken from the end. | Creates a slice of `array` with `n` elements taken from the end. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[n=1]` *(number)*: The number of elements to take. | 2. `[n=1]` *(number)*: The number of elements to take. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
_.takeRight([1, 2, 3]); | _.takeRight([1, 2, 3]); | |
// => [3] | // => [3] | |
_.takeRight([1, 2, 3], 2); | _.takeRight([1, 2, 3], 2); | |
// => [2, 3] | // => [2, 3] | |
_.takeRight([1, 2, 3], 5); | _.takeRight([1, 2, 3], 5); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
_.takeRight([1, 2, 3], 0); | _.takeRight([1, 2, 3], 0); | |
// => [] | // => [] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_takerightwhilearray-predicate_identity"></a>`_.takeRightWhile(array, | <h3 id="_takerightwhilearray-predicate_identity"><code>_.takeRightWhile(array, [ | |
[predicate=_.identity])` | predicate=_.identity])</code></h3> | |
<a href="#_takerightwhilearray-predicate_identity">#</a> [Ⓢ](https://gith | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8311 "View i | |
ub.com/lodash/lodash/blob/4.0.0/lodash.js#L6504 "View in source") [Ⓣ][1] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See t | |
[Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm pack | he npm package") [Ⓣ][1] | |
age") | ||
Creates a slice of `array` with elements taken from the end. Elements are | Creates a slice of `array` with elements taken from the end. Elements are | |
taken until `predicate` returns falsey. The predicate is invoked with three | taken until `predicate` returns falsey. The predicate is invoked with | |
arguments: (value, index, array). | three arguments: *(value, index, array)*. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': true }, | { 'user': 'barney', 'active': true }, | |
{ 'user': 'fred', 'active': false }, | { 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': false } | { 'user': 'pebbles', 'active': false } | |
]; | ]; | |
_.takeRightWhile(users, function(o) { return !o.active; }); | _.takeRightWhile(users, function(o) { return !o.active; }); | |
// => objects for ['fred', 'pebbles'] | // => objects for ['fred', 'pebbles'] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); | _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); | |
// => objects for ['pebbles'] | // => objects for ['pebbles'] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.takeRightWhile(users, ['active', false]); | _.takeRightWhile(users, ['active', false]); | |
// => objects for ['fred', 'pebbles'] | // => objects for ['fred', 'pebbles'] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.takeRightWhile(users, 'active'); | _.takeRightWhile(users, 'active'); | |
// => [] | // => [] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_takewhilearray-predicate_identity"></a>`_.takeWhile(array, [predicat | <h3 id="_takewhilearray-predicate_identity"><code>_.takeWhile(array, [predicate= | |
e=_.identity])` | _.identity])</code></h3> | |
<a href="#_takewhilearray-predicate_identity">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8352 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L6544 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the np | |
4C3;](https://www.npmjs.com/package/lodash.takewhile "See the npm package") | m package") [Ⓣ][1] | |
Creates a slice of `array` with elements taken from the beginning. Elements | Creates a slice of `array` with elements taken from the beginning. Elements | |
are taken until `predicate` returns falsey. The predicate is invoked with | are taken until `predicate` returns falsey. The predicate is invoked with | |
three arguments: (value, index, array). | three arguments: *(value, index, array)*. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to query. | 1. `array` *(Array)*: The array to query. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the slice of `array`. | *(Array)*: Returns the slice of `array`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': false }, | { 'user': 'barney', 'active': false }, | |
{ 'user': 'fred', 'active': false}, | { 'user': 'fred', 'active': false }, | |
{ 'user': 'pebbles', 'active': true } | { 'user': 'pebbles', 'active': true } | |
]; | ]; | |
_.takeWhile(users, function(o) { return !o.active; }); | _.takeWhile(users, function(o) { return !o.active; }); | |
// => objects for ['barney', 'fred'] | // => objects for ['barney', 'fred'] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.takeWhile(users, { 'user': 'barney', 'active': false }); | _.takeWhile(users, { 'user': 'barney', 'active': false }); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.takeWhile(users, ['active', false]); | _.takeWhile(users, ['active', false]); | |
// => objects for ['barney', 'fred'] | // => objects for ['barney', 'fred'] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.takeWhile(users, 'active'); | _.takeWhile(users, 'active'); | |
// => [] | // => [] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_unionarrays"></a>`_.union([arrays])` | <h3 id="_unionarrays"><code>_.union([arrays])</code></h3> | |
<a href="#_unionarrays">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8374 "View i | |
.0.0/lodash.js#L6565 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmj | n source") [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm pa | |
s.com/package/lodash.union "See the npm package") | ckage") [Ⓣ][1] | |
Creates an array of unique values, in order, from all of the provided arrays | Creates an array of unique values, in order, from all given arrays using | |
using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevalu | [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | |
ezero) | ||
for equality comparisons. | for equality comparisons. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of combined values. | *(Array)*: Returns the new array of combined values. | |
#### Example | #### Example | |
```js | ```js | |
_.union([2, 1], [4, 2], [1, 2]); | _.union([2], [1, 2]); | |
// => [2, 1, 4] | // => [2, 1] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_unionbyarrays-iteratee_identity"></a>`_.unionBy([arrays], [iteratee= | <h3 id="_unionbyarrays-iteratee_identity"><code>_.unionBy([arrays], [iteratee=_. | |
_.identity])` | identity])</code></h3> | |
<a href="#_unionbyarrays-iteratee_identity">#</a> [Ⓢ](https://github.com/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8401 "View i | |
lodash/lodash/blob/4.0.0/lodash.js#L6589 "View in source") [Ⓣ][1] [Ɍ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.unionby "See the npm | |
3;](https://www.npmjs.com/package/lodash.unionby "See the npm package") | package") [Ⓣ][1] | |
This method is like `_.union` except that it accepts `iteratee` which is | 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 | invoked for each element of each `arrays` to generate the criterion by | |
uniqueness is computed. The iteratee is invoked with one argument: (value). | which uniqueness is computed. Result values are chosen from the first | |
array in which the value occurs. The iteratee is invoked with one argument:<br> | ||
*(value)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of combined values. | *(Array)*: Returns the new array of combined values. | |
#### Example | #### Example | |
```js | ```js | |
_.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor); | _.unionBy([2.1], [1.2, 2.3], Math.floor); | |
// => [2.1, 1.2, 4.3] | // => [2.1, 1.2] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); | _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); | |
// => [{ 'x': 1 }, { 'x': 2 }] | // => [{ 'x': 1 }, { 'x': 2 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_unionwitharrays-comparator"></a>`_.unionWith([arrays], [comparator]) | <h3 id="_unionwitharrays-comparator"><code>_.unionWith([arrays], [comparator])</ | |
` | code></h3> | |
<a href="#_unionwitharrays-comparator">#</a> [Ⓢ](https://github.com/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8430 "View i | |
h/lodash/blob/4.0.0/lodash.js#L6616 "View in source") [Ⓣ][1] [Ⓝ](h | n source") [Ⓝ](https://www.npmjs.com/package/lodash.unionwith "See the np | |
ttps://www.npmjs.com/package/lodash.unionwith "See the npm package") | m package") [Ⓣ][1] | |
This method is like `_.union` except that it accepts `comparator` which | This method is like `_.union` except that it accepts `comparator` which | |
is invoked to compare elements of `arrays`. The comparator is invoked | is invoked to compare elements of `arrays`. Result values are chosen from | |
with two arguments: (arrVal, othVal). | the first array in which the value occurs. The comparator is invoked | |
with two arguments: *(arrVal, othVal)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
2. `[comparator]` *(Function)*: The comparator invoked per element. | 2. `[comparator]` *(Function)*: The comparator invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of combined values. | *(Array)*: Returns the new array of combined values. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | |
var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; | var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; | |
_.unionWith(objects, others, _.isEqual); | _.unionWith(objects, others, _.isEqual); | |
// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] | // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_uniqarray"></a>`_.uniq(array)` | <h3 id="_uniqarray"><code>_.uniq(array)</code></h3> | |
<a href="#_uniqarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8454 "View i | |
.0/lodash.js#L6640 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm pac | |
com/package/lodash.uniq "See the npm package") | kage") [Ⓣ][1] | |
Creates a duplicate-free version of an array, using | Creates a duplicate-free version of an array, using | |
[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | |
for equality comparisons, in which only the first occurrence of each element | for equality comparisons, in which only the first occurrence of each element | |
is kept. | is kept. The order of result values is determined by the order they occur | |
in the array. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new duplicate free array. | *(Array)*: Returns the new duplicate free array. | |
#### Example | #### Example | |
```js | ```js | |
_.uniq([2, 1, 2]); | _.uniq([2, 1, 2]); | |
// => [2, 1] | // => [2, 1] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_uniqbyarray-iteratee_identity"></a>`_.uniqBy(array, [iteratee=_.iden | <h3 id="_uniqbyarray-iteratee_identity"><code>_.uniqBy(array, [iteratee=_.identi | |
tity])` | ty])</code></h3> | |
<a href="#_uniqbyarray-iteratee_identity">#</a> [Ⓢ](https://github.com/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8481 "View i | |
dash/lodash/blob/4.0.0/lodash.js#L6666 "View in source") [Ⓣ][1] [Ⓝ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.uniqby "See the npm p | |
](https://www.npmjs.com/package/lodash.uniqby "See the npm package") | ackage") [Ⓣ][1] | |
This method is like `_.uniq` except that it accepts `iteratee` which is | This method is like `_.uniq` except that it accepts `iteratee` which is | |
invoked for each element in `array` to generate the criterion by which | invoked for each element in `array` to generate the criterion by which | |
uniqueness is computed. The iteratee is invoked with one argument: (value). | uniqueness is computed. The order of result values is determined by the | |
order they occur in the array. The iteratee is invoked with one argument:<br> | ||
*(value)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new duplicate free array. | *(Array)*: Returns the new duplicate free array. | |
#### Example | #### Example | |
```js | ```js | |
_.uniqBy([2.1, 1.2, 2.3], Math.floor); | _.uniqBy([2.1, 1.2, 2.3], Math.floor); | |
// => [2.1, 1.2] | // => [2.1, 1.2] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); | _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); | |
// => [{ 'x': 1 }, { 'x': 2 }] | // => [{ 'x': 1 }, { 'x': 2 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_uniqwitharray-comparator"></a>`_.uniqWith(array, [comparator])` | <h3 id="_uniqwitharray-comparator"><code>_.uniqWith(array, [comparator])</code>< | |
<a href="#_uniqwitharray-comparator">#</a> [Ⓢ](https://github.com/lodash/ | /h3> | |
lodash/blob/4.0.0/lodash.js#L6690 "View in source") [Ⓣ][1] [Ⓝ](htt | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8505 "View i | |
ps://www.npmjs.com/package/lodash.uniqwith "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.uniqwith "See the npm | |
package") [Ⓣ][1] | ||
This method is like `_.uniq` except that it accepts `comparator` which | This method is like `_.uniq` except that it accepts `comparator` which | |
is invoked to compare elements of `array`. The comparator is invoked with | is invoked to compare elements of `array`. The order of result values is | |
two arguments: (arrVal, othVal). | determined by the order they occur in the array.The comparator is invoked | |
with two arguments: *(arrVal, othVal)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to inspect. | 1. `array` *(Array)*: The array to inspect. | |
2. `[comparator]` *(Function)*: The comparator invoked per element. | 2. `[comparator]` *(Function)*: The comparator invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new duplicate free array. | *(Array)*: Returns the new duplicate free array. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; | var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; | |
_.uniqWith(objects, _.isEqual); | _.uniqWith(objects, _.isEqual); | |
// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] | // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_unziparray"></a>`_.unzip(array)` | <h3 id="_unziparray"><code>_.unzip(array)</code></h3> | |
<a href="#_unziparray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8529 "View i | |
0.0/lodash.js#L6714 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs | n source") [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm pa | |
.com/package/lodash.unzip "See the npm package") | ckage") [Ⓣ][1] | |
This method is like `_.zip` except that it accepts an array of grouped | 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 | elements and creates an array regrouping the elements to their pre-zip | |
configuration. | configuration. | |
#### Since | ||
1.2.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array of grouped elements to process. | 1. `array` *(Array)*: The array of grouped elements to process. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of regrouped elements. | *(Array)*: Returns the new array of regrouped elements. | |
#### Example | #### Example | |
```js | ```js | |
var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]); | var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); | |
// => [['fred', 30, true], ['barney', 40, false]] | // => [['a', 1, true], ['b', 2, false]] | |
_.unzip(zipped); | _.unzip(zipped); | |
// => [['fred', 'barney'], [30, 40], [true, false]] | // => [['a', 'b'], [1, 2], [true, false]] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_unzipwitharray-iteratee_identity"></a>`_.unzipWith(array, [iteratee= | <h3 id="_unzipwitharray-iteratee_identity"><code>_.unzipWith(array, [iteratee=_. | |
_.identity])` | identity])</code></h3> | |
<a href="#_unzipwitharray-iteratee_identity">#</a> [Ⓢ](https://github.com | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8566 "View i | |
/lodash/lodash/blob/4.0.0/lodash.js#L6749 "View in source") [Ⓣ][1] [$ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.unzipwith "See the np | |
C3;](https://www.npmjs.com/package/lodash.unzipwith "See the npm package") | m package") [Ⓣ][1] | |
This method is like `_.unzip` except that it accepts `iteratee` to specify | This method is like `_.unzip` except that it accepts `iteratee` to specify | |
how regrouped values should be combined. The iteratee is invoked with the | how regrouped values should be combined. The iteratee is invoked with the | |
elements of each group: (...group). | elements of each group: *(...group)*. | |
#### Since | ||
3.8.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array of grouped elements to process. | 1. `array` *(Array)*: The array of grouped elements to process. | |
2. `[iteratee=_.identity]` *(Function)*: The function to combine regrouped value s. | 2. `[iteratee=_.identity]` *(Function)*: The function to combine regrouped value s. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of regrouped elements. | *(Array)*: Returns the new array of regrouped elements. | |
#### Example | #### Example | |
```js | ```js | |
var zipped = _.zip([1, 2], [10, 20], [100, 200]); | var zipped = _.zip([1, 2], [10, 20], [100, 200]); | |
// => [[1, 10, 100], [2, 20, 200]] | // => [[1, 10, 100], [2, 20, 200]] | |
_.unzipWith(zipped, _.add); | _.unzipWith(zipped, _.add); | |
// => [3, 30, 300] | // => [3, 30, 300] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_withoutarray-values"></a>`_.without(array, [values])` | <h3 id="_withoutarray-values"><code>_.without(array, [values])</code></h3> | |
<a href="#_withoutarray-values">#</a> [Ⓢ](https://github.com/lodash/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8599 "View i | |
h/blob/4.0.0/lodash.js#L6778 "View in source") [Ⓣ][1] [Ⓝ](https:// | n source") [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm | |
www.npmjs.com/package/lodash.without "See the npm package") | package") [Ⓣ][1] | |
Creates an array excluding all provided values using | Creates an array excluding all given values using | |
[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | |
for equality comparisons. | for equality comparisons. | |
<br> | ||
<br> | ||
**Note:** Unlike `_.pull`, this method returns a new array. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to filter. | 1. `array` *(Array)*: The array to inspect. | |
2. `[values]` *(...*)*: The values to exclude. | 2. `[values]` *(...*)*: The values to exclude. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of filtered values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
_.without([1, 2, 1, 3], 1, 2); | _.without([2, 1, 2, 3], 1, 2); | |
// => [3] | // => [3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_xorarrays"></a>`_.xor([arrays])` | <h3 id="_xorarrays"><code>_.xor([arrays])</code></h3> | |
<a href="#_xorarrays">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8623 "View i | |
.0/lodash.js#L6798 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm pack | |
com/package/lodash.xor "See the npm package") | age") [Ⓣ][1] | |
Creates an array of unique values that is the [symmetric difference](https://en. | Creates an array of unique values that is the | |
wikipedia.org/wiki/Symmetric_difference) | [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) | |
of the provided arrays. | of the given arrays. The order of result values is determined by the order | |
they occur in the arrays. | ||
#### Since | ||
2.4.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
_.xor([2, 1], [4, 2]); | _.xor([2, 1], [2, 3]); | |
// => [1, 4] | // => [1, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_xorbyarrays-iteratee_identity"></a>`_.xorBy([arrays], [iteratee=_.id | <h3 id="_xorbyarrays-iteratee_identity"><code>_.xorBy([arrays], [iteratee=_.iden | |
entity])` | tity])</code></h3> | |
<a href="#_xorbyarrays-iteratee_identity">#</a> [Ⓢ](https://github.com/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8650 "View i | |
dash/lodash/blob/4.0.0/lodash.js#L6822 "View in source") [Ⓣ][1] [Ⓝ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.xorby "See the npm pa | |
](https://www.npmjs.com/package/lodash.xorby "See the npm package") | ckage") [Ⓣ][1] | |
This method is like `_.xor` except that it accepts `iteratee` which is | 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 | invoked for each element of each `arrays` to generate the criterion by | |
uniqueness is computed. The iteratee is invoked with one argument: (value). | which by which they're compared. The order of result values is determined | |
by the order they occur in the arrays. The iteratee is invoked with one | ||
argument: *(value)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
_.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); | _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); | |
// => [1.2, 4.3] | // => [1.2, 3.4] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); | _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); | |
// => [{ 'x': 2 }] | // => [{ 'x': 2 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_xorwitharrays-comparator"></a>`_.xorWith([arrays], [comparator])` | <h3 id="_xorwitharrays-comparator"><code>_.xorWith([arrays], [comparator])</code | |
<a href="#_xorwitharrays-comparator">#</a> [Ⓢ](https://github.com/lodash/ | ></h3> | |
lodash/blob/4.0.0/lodash.js#L6849 "View in source") [Ⓣ][1] [Ⓝ](htt | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8679 "View i | |
ps://www.npmjs.com/package/lodash.xorwith "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.xorwith "See the npm | |
package") [Ⓣ][1] | ||
This method is like `_.xor` except that it accepts `comparator` which is | This method is like `_.xor` except that it accepts `comparator` which is | |
invoked to compare elements of `arrays`. The comparator is invoked with | invoked to compare elements of `arrays`. The order of result values is | |
two arguments: (arrVal, othVal). | determined by the order they occur in the arrays. The comparator is invoked | |
with two arguments: *(arrVal, othVal)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to inspect. | 1. `[arrays]` *(...Array)*: The arrays to inspect. | |
2. `[comparator]` *(Function)*: The comparator invoked per element. | 2. `[comparator]` *(Function)*: The comparator invoked per element. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of values. | *(Array)*: Returns the new array of filtered values. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; | |
var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; | var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; | |
_.xorWith(objects, others, _.isEqual); | _.xorWith(objects, others, _.isEqual); | |
// => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] | // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_ziparrays"></a>`_.zip([arrays])` | <h3 id="_ziparrays"><code>_.zip([arrays])</code></h3> | |
<a href="#_ziparrays">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8701 "View i | |
.0/lodash.js#L6872 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | n source") [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm pack | |
com/package/lodash.zip "See the npm package") | age") [Ⓣ][1] | |
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. | ||
Creates an array of grouped elements, the first of which contains the first | #### Since | |
elements of the given arrays, the second of which contains the second elements | 0.1.0 | |
of the given arrays, and so on. | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to process. | 1. `[arrays]` *(...Array)*: The arrays to process. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of grouped elements. | *(Array)*: Returns the new array of grouped elements. | |
#### Example | #### Example | |
```js | ```js | |
_.zip(['fred', 'barney'], [30, 40], [true, false]); | _.zip(['a', 'b'], [1, 2], [true, false]); | |
// => [['fred', 30, true], ['barney', 40, false]] | // => [['a', 1, true], ['b', 2, false]] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_zipobjectprops-values"></a>`_.zipObject([props=[]], [values=[]])` | <h3 id="_zipobjectprops-values"><code>_.zipObject([props=[]], [values=[]])</code | |
<a href="#_zipobjectprops-values">#</a> [Ⓢ](https://github.com/lodash/lod | ></h3> | |
ash/blob/4.0.0/lodash.js#L6889 "View in source") [Ⓣ][1] [Ⓝ](https: | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8719 "View i | |
//www.npmjs.com/package/lodash.zipobject "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the np | |
m package") [Ⓣ][1] | ||
This method is like `_.fromPairs` except that it accepts two arrays, | This method is like `_.fromPairs` except that it accepts two arrays, | |
one of property names and one of corresponding values. | one of property identifiers and one of corresponding values. | |
#### Since | ||
0.4.0 | ||
#### Arguments | #### Arguments | |
1. `[props=[]]` *(Array)*: The property names. | 1. `[props=[]]` *(Array)*: The property identifiers. | |
2. `[values=[]]` *(Array)*: The property values. | 2. `[values=[]]` *(Array)*: The property values. | |
#### Returns | #### Returns | |
*(Object)*: Returns the new object. | *(Object)*: Returns the new object. | |
#### Example | #### Example | |
```js | ```js | |
_.zipObject(['fred', 'barney'], [30, 40]); | _.zipObject(['a', 'b'], [1, 2]); | |
// => { 'fred': 30, 'barney': 40 } | // => { 'a': 1, 'b': 2 } | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_zipwitharrays-iteratee_identity"></a>`_.zipWith([arrays], [iteratee= | <h3 id="_zipobjectdeepprops-values"><code>_.zipObjectDeep([props=[]], [values=[] | |
_.identity])` | ])</code></h3> | |
<a href="#_zipwitharrays-iteratee_identity">#</a> [Ⓢ](https://github.com/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8738 "View i | |
lodash/lodash/blob/4.0.0/lodash.js#L6919 "View in source") [Ⓣ][1] [Ɍ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.zipobjectdeep "See th | |
3;](https://www.npmjs.com/package/lodash.zipwith "See the npm package") | e npm package") [Ⓣ][1] | |
This method is like `_.zip` except that it accepts `iteratee` to specify | This method is like `_.zipObject` except that it supports property paths. | |
how grouped values should be combined. The iteratee is invoked with the | ||
elements of each group: (...group). | #### Since | |
4.1.0 | ||
#### Arguments | #### Arguments | |
1. `[arrays]` *(...Array)*: The arrays to process. | 1. `[props=[]]` *(Array)*: The property identifiers. | |
2. `[iteratee=_.identity]` *(Function)*: The function to combine grouped values. | 2. `[values=[]]` *(Array)*: The property values. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new array of grouped elements. | *(Object)*: Returns the new object. | |
#### Example | #### Example | |
```js | ```js | |
_.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { | _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); | |
return a + b + c; | // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } | |
}); | ||
// => [111, 222] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_prototypereverse"></a>`_.prototype.reverse()` | <h3 id="_zipwitharrays-iteratee_identity"><code>_.zipWith([arrays], [iteratee=_. | |
<a href="#_prototypereverse">#</a> [Ⓢ](https://github.com/lodash/lodash/b | identity])</code></h3> | |
lob/4.0.0/lodash.js#L6169 "View in source") [Ⓣ][1] [Ⓝ](https://www | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L8762 "View i | |
.npmjs.com/package/lodash.reverse "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.zipwith "See the npm | |
package") [Ⓣ][1] | ||
Reverses `array` so that the first element becomes the last, the second | This method is like `_.zip` except that it accepts `iteratee` to specify | |
element becomes the second to last, and so on. | how grouped values should be combined. The iteratee is invoked with the | |
<br> | elements of each group: *(...group)*. | |
<br> | ||
**Note:** This method mutates `array` and is based on | #### Since | |
[`Array#reverse`](https://mdn.io/Array/reverse). | 3.8.0 | |
#### Arguments | ||
1. `[arrays]` *(...Array)*: The arrays to process. | ||
2. `[iteratee=_.identity]` *(Function)*: The function to combine grouped values. | ||
#### Returns | #### Returns | |
*(Array)*: Returns `array`. | *(Array)*: Returns the new array of grouped elements. | |
#### Example | #### Example | |
```js | ```js | |
var array = [1, 2, 3]; | _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { | |
return a + b + c; | ||
_.reverse(array); | }); | |
// => [3, 2, 1] | // => [111, 222] | |
console.log(array); | ||
// => [3, 2, 1] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `“Collection” Methods` | ## `“Collection” Methods` | |
<!-- div --> | <!-- div --> | |
### <a id="_countbycollection-iteratee_identity"></a>`_.countBy(collection, [ite | <h3 id="_countbycollection-iteratee_identity"><code>_.countBy(collection, [itera | |
ratee=_.identity])` | tee=_.identity])</code></h3> | |
<a href="#_countbycollection-iteratee_identity">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9141 "View i | |
com/lodash/lodash/blob/4.0.0/lodash.js#L7299 "View in source") [Ⓣ][1] [&# | n source") [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm | |
x24C3;](https://www.npmjs.com/package/lodash.countby "See the npm package") | package") [Ⓣ][1] | |
Creates an object composed of keys generated from the results of running | Creates an object composed of keys generated from the results of running | |
each element of `collection` through `iteratee`. The corresponding value | each element of `collection` thru `iteratee`. The corresponding value of | |
of each key is the number of times the key was returned by `iteratee`. | each key is the number of times the key was returned by `iteratee`. The | |
The iteratee is invoked with one argument: (value). | iteratee is invoked with one argument: *(value)*. | |
#### Since | ||
0.5.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee to transform keys. | |
#### Returns | #### Returns | |
*(Object)*: Returns the composed aggregate object. | *(Object)*: Returns the composed aggregate object. | |
#### Example | #### Example | |
```js | ```js | |
_.countBy([6.1, 4.2, 6.3], Math.floor); | _.countBy([6.1, 4.2, 6.3], Math.floor); | |
// => { '4': 1, '6': 2 } | // => { '4': 1, '6': 2 } | |
// The `_.property` iteratee shorthand. | ||
_.countBy(['one', 'two', 'three'], 'length'); | _.countBy(['one', 'two', 'three'], 'length'); | |
// => { '3': 2, '5': 1 } | // => { '3': 2, '5': 1 } | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_everycollection-predicate_identity"></a>`_.every(collection, [predic | <h3 id="_everycollection-predicate_identity"><code>_.every(collection, [predicat | |
ate=_.identity])` | e=_.identity])</code></h3> | |
<a href="#_everycollection-predicate_identity">#</a> [Ⓢ](https://github.c | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9190 "View i | |
om/lodash/lodash/blob/4.0.0/lodash.js#L7337 "View in source") [Ⓣ][1] [&#x | n source") [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm pa | |
24C3;](https://www.npmjs.com/package/lodash.every "See the npm package") | ckage") [Ⓣ][1] | |
Checks if `predicate` returns truthy for **all** elements of `collection`. | Checks if `predicate` returns truthy for **all** elements of `collection`. | |
Iteration is stopped once `predicate` returns falsey. The predicate is | Iteration is stopped once `predicate` returns falsey. The predicate is | |
invoked with three arguments: (value, index|key, collection). | invoked with three arguments: *(value, index|key, collection)*. | |
<br> | ||
<br> | ||
**Note:** This method returns `true` for | ||
[empty collections](https://en.wikipedia.org/wiki/Empty_set) because | ||
[everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of | ||
elements of empty collections. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if all elements pass the predicate check, else `fal se`. | *(boolean)*: Returns `true` if all elements pass the predicate check, else `fals e`. | |
#### Example | #### Example | |
```js | ```js | |
_.every([true, 1, null, 'yes'], Boolean); | _.every([true, 1, null, 'yes'], Boolean); | |
// => false | // => false | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': false }, | { 'user': 'barney', 'age': 36, 'active': false }, | |
{ 'user': 'fred', 'active': false } | { 'user': 'fred', 'age': 40, 'active': false } | |
]; | ]; | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.every(users, { 'user': 'barney', 'active': false }); | _.every(users, { 'user': 'barney', 'active': false }); | |
// => false | // => false | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.every(users, ['active', false]); | _.every(users, ['active', false]); | |
// => true | // => true | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.every(users, 'active'); | _.every(users, 'active'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_filtercollection-predicate_identity"></a>`_.filter(collection, [pred | <h3 id="_filtercollection-predicate_identity"><code>_.filter(collection, [predic | |
icate=_.identity])` | ate=_.identity])</code></h3> | |
<a href="#_filtercollection-predicate_identity">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9239 "View i | |
com/lodash/lodash/blob/4.0.0/lodash.js#L7378 "View in source") [Ⓣ][1] [&# | n source") [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm p | |
x24C3;](https://www.npmjs.com/package/lodash.filter "See the npm package") | ackage") [Ⓣ][1] | |
Iterates over elements of `collection`, returning an array of all elements | Iterates over elements of `collection`, returning an array of all elements | |
`predicate` returns truthy for. The predicate is invoked with three arguments:<b | `predicate` returns truthy for. The predicate is invoked with three | |
r> | arguments: *(value, index|key, collection)*. | |
(value, index|key, collection). | <br> | |
<br> | ||
**Note:** Unlike `_.remove`, this method returns a new array. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new filtered array. | *(Array)*: Returns the new filtered array. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'age': 36, 'active': true }, | { 'user': 'barney', 'age': 36, 'active': true }, | |
{ 'user': 'fred', 'age': 40, 'active': false } | { 'user': 'fred', 'age': 40, 'active': false } | |
]; | ]; | |
_.filter(users, function(o) { return !o.active; }); | _.filter(users, function(o) { return !o.active; }); | |
// => objects for ['fred'] | // => objects for ['fred'] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.filter(users, { 'age': 36, 'active': true }); | _.filter(users, { 'age': 36, 'active': true }); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.filter(users, ['active', false]); | _.filter(users, ['active', false]); | |
// => objects for ['fred'] | // => objects for ['fred'] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.filter(users, 'active'); | _.filter(users, 'active'); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
// Combining several predicates using `_.overEvery` or `_.overSome`. | ||
_.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); | ||
// => objects for ['fred', 'barney'] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_findcollection-predicate_identity"></a>`_.find(collection, [predicat | <h3 id="_findcollection-predicate_identity-fromindex0"><code>_.find(collection, | |
e=_.identity])` | [predicate=_.identity], [fromIndex=0])</code></h3> | |
<a href="#_findcollection-predicate_identity">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9280 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L7417 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm pac | |
4C3;](https://www.npmjs.com/package/lodash.find "See the npm package") | kage") [Ⓣ][1] | |
Iterates over elements of `collection`, returning the first element | Iterates over elements of `collection`, returning the first element | |
`predicate` returns truthy for. The predicate is invoked with three arguments:<b | `predicate` returns truthy for. The predicate is invoked with three | |
r> | arguments: *(value, index|key, collection)*. | |
(value, index|key, collection). | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to search. | 1. `collection` *(Array|Object)*: The collection to inspect. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
iteration. | 3. `[fromIndex=0]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(*)*: Returns the matched element, else `undefined`. | *(*)*: Returns the matched element, else `undefined`. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'age': 36, 'active': true }, | { 'user': 'barney', 'age': 36, 'active': true }, | |
{ 'user': 'fred', 'age': 40, 'active': false }, | { 'user': 'fred', 'age': 40, 'active': false }, | |
{ 'user': 'pebbles', 'age': 1, 'active': true } | { 'user': 'pebbles', 'age': 1, 'active': true } | |
]; | ]; | |
_.find(users, function(o) { return o.age < 40; }); | _.find(users, function(o) { return o.age < 40; }); | |
// => object for 'barney' | // => object for 'barney' | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.find(users, { 'age': 1, 'active': true }); | _.find(users, { 'age': 1, 'active': true }); | |
// => object for 'pebbles' | // => object for 'pebbles' | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.find(users, ['active', false]); | _.find(users, ['active', false]); | |
// => object for 'fred' | // => object for 'fred' | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.find(users, 'active'); | _.find(users, 'active'); | |
// => object for 'barney' | // => object for 'barney' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_findlastcollection-predicate_identity"></a>`_.findLast(collection, [ | <h3 id="_findlastcollection-predicate_identity-fromindexcollectionlength-1"><cod | |
predicate=_.identity])` | e>_.findLast(collection, [predicate=_.identity], [fromIndex=collection.length-1] | |
<a href="#_findlastcollection-predicate_identity">#</a> [Ⓢ](https://githu | )</code></h3> | |
b.com/lodash/lodash/blob/4.0.0/lodash.js#L7443 "View in source") [Ⓣ][1] [ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9301 "View i | |
Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm | |
package") [Ⓣ][1] | ||
This method is like `_.find` except that it iterates over elements of | This method is like `_.find` except that it iterates over elements of | |
`collection` from right to left. | `collection` from right to left. | |
#### Since | ||
2.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to search. | 1. `collection` *(Array|Object)*: The collection to inspect. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
iteration. | 3. `[fromIndex=collection.length-1]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(*)*: Returns the matched element, else `undefined`. | *(*)*: Returns the matched element, else `undefined`. | |
#### Example | #### Example | |
```js | ```js | |
_.findLast([1, 2, 3, 4], function(n) { | _.findLast([1, 2, 3, 4], function(n) { | |
return n % 2 == 1; | return n % 2 == 1; | |
}); | }); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_foreachcollection-iteratee_identity"></a>`_.forEach(collection, [ite | <h3 id="_flatmapcollection-iteratee_identity"><code>_.flatMap(collection, [itera | |
ratee=_.identity])` | tee=_.identity])</code></h3> | |
<a href="#_foreachcollection-iteratee_identity">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9324 "View i | |
com/lodash/lodash/blob/4.0.0/lodash.js#L7480 "View in source") [Ⓣ][1] [&# | n source") [Ⓝ](https://www.npmjs.com/package/lodash.flatmap "See the npm | |
x24C3;](https://www.npmjs.com/package/lodash.foreach "See the npm package") | package") [Ⓣ][1] | |
Creates a flattened array of values by running each element in `collection` | ||
thru `iteratee` and flattening the mapped results. The iteratee is invoked | ||
with three arguments: *(value, index|key, collection)*. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | ||
1. `collection` *(Array|Object)*: The collection to iterate over. | ||
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | ||
#### Returns | ||
*(Array)*: Returns the new flattened array. | ||
#### Example | ||
```js | ||
function duplicate(n) { | ||
return [n, n]; | ||
} | ||
_.flatMap([1, 2], duplicate); | ||
// => [1, 1, 2, 2] | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_flatmapdeepcollection-iteratee_identity"><code>_.flatMapDeep(collection | ||
, [iteratee=_.identity])</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9348 "View i | ||
n source") [Ⓝ](https://www.npmjs.com/package/lodash.flatmapdeep "See the | ||
npm package") [Ⓣ][1] | ||
This method is like `_.flatMap` except that it recursively flattens the | ||
mapped results. | ||
#### Since | ||
4.7.0 | ||
#### Arguments | ||
1. `collection` *(Array|Object)*: The collection to iterate over. | ||
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | ||
#### Returns | ||
*(Array)*: Returns the new flattened array. | ||
#### Example | ||
```js | ||
function duplicate(n) { | ||
return [[[n, n]]]; | ||
} | ||
Iterates over elements of `collection` invoking `iteratee` for each element. | _.flatMapDeep([1, 2], duplicate); | |
The iteratee is invoked with three arguments: (value, index|key, collection). | // => [1, 1, 2, 2] | |
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_flatmapdepthcollection-iteratee_identity-depth1"><code>_.flatMapDepth(c | ||
ollection, [iteratee=_.identity], [depth=1])</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9373 "View i | ||
n source") [Ⓝ](https://www.npmjs.com/package/lodash.flatmapdepth "See the | ||
npm package") [Ⓣ][1] | ||
This method is like `_.flatMap` except that it recursively flattens the | ||
mapped results up to `depth` times. | ||
#### Since | ||
4.7.0 | ||
#### Arguments | ||
1. `collection` *(Array|Object)*: The collection to iterate over. | ||
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | ||
3. `[depth=1]` *(number)*: The maximum recursion depth. | ||
#### Returns | ||
*(Array)*: Returns the new flattened array. | ||
#### Example | ||
```js | ||
function duplicate(n) { | ||
return [[[n, n]]]; | ||
} | ||
_.flatMapDepth([1, 2], duplicate, 2); | ||
// => [[1, 1], [2, 2]] | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_foreachcollection-iteratee_identity"><code>_.forEach(collection, [itera | ||
tee=_.identity])</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9408 "View i | ||
n source") [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm | ||
package") [Ⓣ][1] | ||
Iterates over elements of `collection` and invokes `iteratee` for each element. | ||
The iteratee is invoked with three arguments: *(value, index|key, collection)*. | ||
Iteratee functions may exit iteration early by explicitly returning `false`. | Iteratee functions may exit iteration early by explicitly returning `false`. | |
<br> | <br> | |
<br> | <br> | |
**Note:** As with other "Collections" methods, objects with a "length" property | **Note:** As with other "Collections" methods, objects with a "length" | |
are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn` | property are iterated like arrays. To avoid this behavior use `_.forIn` | |
for object iteration. | or `_.forOwn` for object iteration. | |
#### Since | ||
0.1.0 | ||
#### Aliases | #### Aliases | |
*_.each* | *_.each* | |
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array|Object)*: Returns `collection`. | *(*)*: Returns `collection`. | |
#### Example | #### Example | |
```js | ```js | |
_([1, 2]).forEach(function(value) { | _.forEach([1, 2], function(value) { | |
console.log(value); | console.log(value); | |
}); | }); | |
// => logs `1` then `2` | // => Logs `1` then `2`. | |
_.forEach({ 'a': 1, 'b': 2 }, function(value, key) { | _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { | |
console.log(key); | console.log(key); | |
}); | }); | |
// => logs 'a' then 'b' (iteration order is not guaranteed) | // => Logs 'a' then 'b' (iteration order is not guaranteed). | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_foreachrightcollection-iteratee_identity"></a>`_.forEachRight(collec | <h3 id="_foreachrightcollection-iteratee_identity"><code>_.forEachRight(collecti | |
tion, [iteratee=_.identity])` | on, [iteratee=_.identity])</code></h3> | |
<a href="#_foreachrightcollection-iteratee_identity">#</a> [Ⓢ](https://gi | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9433 "View i | |
thub.com/lodash/lodash/blob/4.0.0/lodash.js#L7504 "View in source") [Ⓣ][1 | n source") [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the | |
] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm pack | npm package") [Ⓣ][1] | |
age") | ||
This method is like `_.forEach` except that it iterates over elements of | This method is like `_.forEach` except that it iterates over elements of | |
`collection` from right to left. | `collection` from right to left. | |
#### Since | ||
2.0.0 | ||
#### Aliases | #### Aliases | |
*_.eachRight* | *_.eachRight* | |
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array|Object)*: Returns `collection`. | *(*)*: Returns `collection`. | |
#### Example | #### Example | |
```js | ```js | |
_.forEachRight([1, 2], function(value) { | _.forEachRight([1, 2], function(value) { | |
console.log(value); | console.log(value); | |
}); | }); | |
// => logs `2` then `1` | // => Logs `2` then `1`. | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_groupbycollection-iteratee_identity"></a>`_.groupBy(collection, [ite | <h3 id="_groupbycollection-iteratee_identity"><code>_.groupBy(collection, [itera | |
ratee=_.identity])` | tee=_.identity])</code></h3> | |
<a href="#_groupbycollection-iteratee_identity">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9461 "View i | |
com/lodash/lodash/blob/4.0.0/lodash.js#L7531 "View in source") [Ⓣ][1] [&# | n source") [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm | |
x24C3;](https://www.npmjs.com/package/lodash.groupby "See the npm package") | package") [Ⓣ][1] | |
Creates an object composed of keys generated from the results of running | Creates an object composed of keys generated from the results of running | |
each element of `collection` through `iteratee`. The corresponding value | each element of `collection` thru `iteratee`. The order of grouped values | |
of each key is an array of the elements responsible for generating the key. | is determined by the order they occur in `collection`. The corresponding | |
The iteratee is invoked with one argument: (value). | value of each key is an array of elements responsible for generating the | |
key. The iteratee is invoked with one argument: *(value)*. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee to transform keys. | |
#### Returns | #### Returns | |
*(Object)*: Returns the composed aggregate object. | *(Object)*: Returns the composed aggregate object. | |
#### Example | #### Example | |
```js | ```js | |
_.groupBy([6.1, 4.2, 6.3], Math.floor); | _.groupBy([6.1, 4.2, 6.3], Math.floor); | |
// => { '4': [4.2], '6': [6.1, 6.3] } | // => { '4': [4.2], '6': [6.1, 6.3] } | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.groupBy(['one', 'two', 'three'], 'length'); | _.groupBy(['one', 'two', 'three'], 'length'); | |
// => { '3': ['one', 'two'], '5': ['three'] } | // => { '3': ['one', 'two'], '5': ['three'] } | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_includescollection-value-fromindex0"></a>`_.includes(collection, val | <h3 id="_includescollection-value-fromindex0"><code>_.includes(collection, value | |
ue, [fromIndex=0])` | , [fromIndex=0])</code></h3> | |
<a href="#_includescollection-value-fromindex0">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9499 "View i | |
com/lodash/lodash/blob/4.0.0/lodash.js#L7567 "View in source") [Ⓣ][1] [&# | n source") [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm | |
x24C3;](https://www.npmjs.com/package/lodash.includes "See the npm package") | package") [Ⓣ][1] | |
Checks if `value` is in `collection`. If `collection` is a string it's checked | Checks if `value` is in `collection`. If `collection` is a string, it's | |
for a substring of `value`, otherwise [`SameValueZero`](http://ecma-internationa | checked for a substring of `value`, otherwise | |
l.org/ecma-262/6.0/#sec-samevaluezero) | [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | |
is used for equality comparisons. If `fromIndex` is negative, it's used as | is used for equality comparisons. If `fromIndex` is negative, it's used as | |
the offset from the end of `collection`. | the offset from the end of `collection`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object|string)*: The collection to search. | 1. `collection` *(Array|Object|string)*: The collection to inspect. | |
2. `value` *(*)*: The value to search for. | 2. `value` *(*)*: The value to search for. | |
3. `[fromIndex=0]` *(number)*: The index to search from. | 3. `[fromIndex=0]` *(number)*: The index to search from. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is found, else `false`. | *(boolean)*: Returns `true` if `value` is found, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.includes([1, 2, 3], 1); | _.includes([1, 2, 3], 1); | |
// => true | // => true | |
_.includes([1, 2, 3], 1, 2); | _.includes([1, 2, 3], 1, 2); | |
// => false | // => false | |
_.includes({ 'user': 'fred', 'age': 40 }, 'fred'); | _.includes({ 'a': 1, 'b': 2 }, 1); | |
// => true | // => true | |
_.includes('pebbles', 'eb'); | _.includes('abcd', 'bc'); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_invokemapcollection-path-args"></a>`_.invokeMap(collection, path, [a | <h3 id="_invokemapcollection-path-args"><code>_.invokeMap(collection, path, [arg | |
rgs])` | s])</code></h3> | |
<a href="#_invokemapcollection-path-args">#</a> [Ⓢ](https://github.com/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9535 "View i | |
dash/lodash/blob/4.0.0/lodash.js#L7602 "View in source") [Ⓣ][1] [Ⓝ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.invokemap "See the np | |
](https://www.npmjs.com/package/lodash.invokemap "See the npm package") | m package") [Ⓣ][1] | |
Invokes the method at `path` of each element in `collection`, returning | Invokes the method at `path` of each element in `collection`, returning | |
an array of the results of each invoked method. Any additional arguments | an array of the results of each invoked method. Any additional arguments | |
are provided to each invoked method. If `methodName` is a function it's | are provided to each invoked method. If `path` is a function, it's invoked | |
invoked for, and `this` bound to, each element in `collection`. | for, and `this` bound to, each element in `collection`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `path` *(Array|Function|string)*: The path of the method to invoke or the fun ction invoked per iteration. | 2. `path` *(Array|Function|string)*: The path of the method to invoke or the fun ction invoked per iteration. | |
3. `[args]` *(...*)*: The arguments to invoke each method with. | 3. `[args]` *(...*)*: The arguments to invoke each method with. | |
#### Returns | #### Returns | |
*(Array)*: Returns the array of results. | *(Array)*: Returns the array of results. | |
#### Example | #### Example | |
```js | ```js | |
_.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); | _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); | |
// => [[1, 5, 7], [1, 2, 3]] | // => [[1, 5, 7], [1, 2, 3]] | |
_.invokeMap([123, 456], String.prototype.split, ''); | _.invokeMap([123, 456], String.prototype.split, ''); | |
// => [['1', '2', '3'], ['4', '5', '6']] | // => [['1', '2', '3'], ['4', '5', '6']] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_keybycollection-iteratee_identity"></a>`_.keyBy(collection, [iterate | <h3 id="_keybycollection-iteratee_identity"><code>_.keyBy(collection, [iteratee= | |
e=_.identity])` | _.identity])</code></h3> | |
<a href="#_keybycollection-iteratee_identity">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9574 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L7642 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.keyby "See the npm pa | |
4C3;](https://www.npmjs.com/package/lodash.keyby "See the npm package") | ckage") [Ⓣ][1] | |
Creates an object composed of keys generated from the results of running | Creates an object composed of keys generated from the results of running | |
each element of `collection` through `iteratee`. The corresponding value | each element of `collection` thru `iteratee`. The corresponding value of | |
of each key is the last element responsible for generating the key. The | each key is the last element responsible for generating the key. The | |
iteratee is invoked with one argument: (value). | iteratee is invoked with one argument: *(value)*. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee to transform keys. | |
#### Returns | #### Returns | |
*(Object)*: Returns the composed aggregate object. | *(Object)*: Returns the composed aggregate object. | |
#### Example | #### Example | |
```js | ```js | |
var keyData = [ | var array = [ | |
{ 'dir': 'left', 'code': 97 }, | { 'dir': 'left', 'code': 97 }, | |
{ 'dir': 'right', 'code': 100 } | { 'dir': 'right', 'code': 100 } | |
]; | ]; | |
_.keyBy(keyData, 'dir'); | _.keyBy(array, function(o) { | |
// => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code' | ||
: 100 } } | ||
_.keyBy(keyData, function(o) { | ||
return String.fromCharCode(o.code); | return String.fromCharCode(o.code); | |
}); | }); | |
// => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } | // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } | |
_.keyBy(array, 'dir'); | ||
// => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code' | ||
: 100 } } | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_mapcollection-iteratee_identity"></a>`_.map(collection, [iteratee=_. | <h3 id="_mapcollection-iteratee_identity"><code>_.map(collection, [iteratee=_.id | |
identity])` | entity])</code></h3> | |
<a href="#_mapcollection-iteratee_identity">#</a> [Ⓢ](https://github.com/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9620 "View i | |
lodash/lodash/blob/4.0.0/lodash.js#L7687 "View in source") [Ⓣ][1] [Ɍ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm pack | |
3;](https://www.npmjs.com/package/lodash.map "See the npm package") | age") [Ⓣ][1] | |
Creates an array of values by running each element in `collection` through | Creates an array of values by running each element in `collection` thru | |
`iteratee`. The iteratee is invoked with three arguments:<br> | `iteratee`. The iteratee is invoked with three arguments:<br> | |
(value, index|key, collection). | *(value, index|key, collection)*. | |
<br> | <br> | |
<br> | <br> | |
Many lodash methods are guarded to work as iteratees for methods like | Many lodash methods are guarded to work as iteratees for methods like | |
`_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. | `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. | |
<br> | <br> | |
<br> | <br> | |
The guarded methods are:<br> | The guarded methods are:<br> | |
`ary`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`, | `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, | |
`invert`, `parseInt`, `random`, `range`, `rangeRight`, `slice`, `some`, | `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, | |
`sortBy`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`, | `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, | |
and `words` | `template`, `trim`, `trimEnd`, `trimStart`, and `words` | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new mapped array. | *(Array)*: Returns the new mapped array. | |
#### Example | #### Example | |
```js | ```js | |
function square(n) { | function square(n) { | |
return n * n; | return n * n; | |
} | } | |
_.map([1, 2], square); | _.map([4, 8], square); | |
// => [3, 6] | // => [16, 64] | |
_.map({ 'a': 1, 'b': 2 }, square); | _.map({ 'a': 4, 'b': 8 }, square); | |
// => [3, 6] (iteration order is not guaranteed) | // => [16, 64] (iteration order is not guaranteed) | |
var users = [ | var users = [ | |
{ 'user': 'barney' }, | { 'user': 'barney' }, | |
{ 'user': 'fred' } | { 'user': 'fred' } | |
]; | ]; | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.map(users, 'user'); | _.map(users, 'user'); | |
// => ['barney', 'fred'] | // => ['barney', 'fred'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_orderbycollection-iteratees-_identity-orders"></a>`_.orderBy(collect | <h3 id="_orderbycollection-iteratees_identity-orders"><code>_.orderBy(collection | |
ion, [iteratees=[_.identity]], [orders])` | , [iteratees=[_.identity]], [orders])</code></h3> | |
<a href="#_orderbycollection-iteratees-_identity-orders">#</a> [Ⓢ](https: | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9654 "View i | |
//github.com/lodash/lodash/blob/4.0.0/lodash.js#L7719 "View in source") [Ⓣ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.orderby "See the npm | |
;][1] [Ⓝ](https://www.npmjs.com/package/lodash.orderby "See the npm packa | package") [Ⓣ][1] | |
ge") | ||
This method is like `_.sortBy` except that it allows specifying the sort | This method is like `_.sortBy` except that it allows specifying the sort | |
orders of the iteratees to sort by. If `orders` is unspecified, all values | orders of the iteratees to sort by. If `orders` is unspecified, all values | |
are sorted in ascending order. Otherwise, specify an order of "desc" for | are sorted in ascending order. Otherwise, specify an order of "desc" for | |
descending or "asc" for ascending sort order of corresponding values. | descending or "asc" for ascending sort order of corresponding values. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratees=[_.identity]]` *(Function[]|Object[]|string[& #93;)*: The iteratees to sort by. | 2. `[iteratees=[_.identity]]` *(Array[]|Function[]|Object[&# 93;|string[])*: The iteratees to sort by. | |
3. `[orders]` *(string[])*: The sort orders of `iteratees`. | 3. `[orders]` *(string[])*: The sort orders of `iteratees`. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new sorted array. | *(Array)*: Returns the new sorted array. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'fred', 'age': 48 }, | { 'user': 'fred', 'age': 48 }, | |
{ 'user': 'barney', 'age': 34 }, | { 'user': 'barney', 'age': 34 }, | |
{ 'user': 'fred', 'age': 42 }, | { 'user': 'fred', 'age': 40 }, | |
{ 'user': 'barney', 'age': 36 } | { 'user': 'barney', 'age': 36 } | |
]; | ]; | |
// sort by `user` in ascending order and by `age` in descending order | // Sort by `user` in ascending order and by `age` in descending order. | |
_.orderBy(users, ['user', 'age'], ['asc', 'desc']); | _.orderBy(users, ['user', 'age'], ['asc', 'desc']); | |
// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] | // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_partitioncollection-predicate_identity"></a>`_.partition(collection, | <h3 id="_partitioncollection-predicate_identity"><code>_.partition(collection, [ | |
[predicate=_.identity])` | predicate=_.identity])</code></h3> | |
<a href="#_partitioncollection-predicate_identity">#</a> [Ⓢ](https://gith | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9704 "View i | |
ub.com/lodash/lodash/blob/4.0.0/lodash.js#L7768 "View in source") [Ⓣ][1] | n source") [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the np | |
[Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") | m package") [Ⓣ][1] | |
Creates an array of elements split into two groups, the first of which | Creates an array of elements split into two groups, the first of which | |
contains elements `predicate` returns truthy for, while the second of which | contains elements `predicate` returns truthy for, the second of which | |
contains elements `predicate` returns falsey for. The predicate is invoked | contains elements `predicate` returns falsey for. The predicate is | |
with three arguments: (value, index|key, collection). | invoked with one argument: *(value)*. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the array of grouped elements. | *(Array)*: Returns the array of grouped elements. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'age': 36, 'active': false }, | { 'user': 'barney', 'age': 36, 'active': false }, | |
{ 'user': 'fred', 'age': 40, 'active': true }, | { 'user': 'fred', 'age': 40, 'active': true }, | |
{ 'user': 'pebbles', 'age': 1, 'active': false } | { 'user': 'pebbles', 'age': 1, 'active': false } | |
]; | ]; | |
_.partition(users, function(o) { return o.active; }); | _.partition(users, function(o) { return o.active; }); | |
// => objects for [['fred'], ['barney', 'pebbles']] | // => objects for [['fred'], ['barney', 'pebbles']] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.partition(users, { 'age': 1, 'active': false }); | _.partition(users, { 'age': 1, 'active': false }); | |
// => objects for [['pebbles'], ['barney', 'fred']] | // => objects for [['pebbles'], ['barney', 'fred']] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.partition(users, ['active', false]); | _.partition(users, ['active', false]); | |
// => objects for [['barney', 'pebbles'], ['fred']] | // => objects for [['barney', 'pebbles'], ['fred']] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.partition(users, 'active'); | _.partition(users, 'active'); | |
// => objects for [['fred'], ['barney', 'pebbles']] | // => objects for [['fred'], ['barney', 'pebbles']] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_reducecollection-iteratee_identity-accumulator"></a>`_.reduce(collec | <h3 id="_reducecollection-iteratee_identity-accumulator"><code>_.reduce(collecti | |
tion, [iteratee=_.identity], [accumulator])` | on, [iteratee=_.identity], [accumulator])</code></h3> | |
<a href="#_reducecollection-iteratee_identity-accumulator">#</a> [Ⓢ](http | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9745 "View i | |
s://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7807 "View in source") [$ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm p | |
C9;][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm pack | ackage") [Ⓣ][1] | |
age") | ||
Reduces `collection` to a value which is the accumulated result of running | Reduces `collection` to a value which is the accumulated result of running | |
each element in `collection` through `iteratee`, where each successive | each element in `collection` thru `iteratee`, where each successive | |
invocation is supplied the return value of the previous. If `accumulator` | invocation is supplied the return value of the previous. If `accumulator` | |
is not provided the first element of `collection` is used as the initial | is not given, the first element of `collection` is used as the initial | |
value. The iteratee is invoked with four arguments:<br> | value. The iteratee is invoked with four arguments:<br> | |
(accumulator, value, index|key, collection). | *(accumulator, value, index|key, collection)*. | |
<br> | <br> | |
<br> | <br> | |
Many lodash methods are guarded to work as iteratees for methods like | Many lodash methods are guarded to work as iteratees for methods like | |
`_.reduce`, `_.reduceRight`, and `_.transform`. | `_.reduce`, `_.reduceRight`, and `_.transform`. | |
<br> | <br> | |
<br> | <br> | |
The guarded methods are:<br> | The guarded methods are:<br> | |
`assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, | `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, | |
and `sortBy` | and `sortBy` | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | |
3. `[accumulator]` *(*)*: The initial value. | 3. `[accumulator]` *(*)*: The initial value. | |
#### Returns | #### Returns | |
*(*)*: Returns the accumulated value. | *(*)*: Returns the accumulated value. | |
#### Example | #### Example | |
```js | ```js | |
_.reduce([1, 2], function(sum, n) { | _.reduce([1, 2], function(sum, n) { | |
return sum + n; | return sum + n; | |
}); | }, 0); | |
// => 3 | // => 3 | |
_.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { | _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { | |
(result[value] || (result[value] = [])).push(key); | (result[value] || (result[value] = [])).push(key); | |
return result; | return result; | |
}, {}); | }, {}); | |
// => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) | // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_reducerightcollection-iteratee_identity-accumulator"></a>`_.reduceRi | <h3 id="_reducerightcollection-iteratee_identity-accumulator"><code>_.reduceRigh | |
ght(collection, [iteratee=_.identity], [accumulator])` | t(collection, [iteratee=_.identity], [accumulator])</code></h3> | |
<a href="#_reducerightcollection-iteratee_identity-accumulator">#</a> [Ⓢ] | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9774 "View i | |
(https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7834 "View in source") [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the | |
Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See th | npm package") [Ⓣ][1] | |
e npm package") | ||
This method is like `_.reduce` except that it iterates over elements of | This method is like `_.reduce` except that it iterates over elements of | |
`collection` from right to left. | `collection` from right to left. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. | |
3. `[accumulator]` *(*)*: The initial value. | 3. `[accumulator]` *(*)*: The initial value. | |
#### Returns | #### Returns | |
*(*)*: Returns the accumulated value. | *(*)*: Returns the accumulated value. | |
#### Example | #### Example | |
```js | ```js | |
var array = [[0, 1], [2, 3], [4, 5]]; | var array = [[0, 1], [2, 3], [4, 5]]; | |
_.reduceRight(array, function(flattened, other) { | _.reduceRight(array, function(flattened, other) { | |
return flattened.concat(other); | return flattened.concat(other); | |
}, []); | }, []); | |
// => [4, 5, 2, 3, 0, 1] | // => [4, 5, 2, 3, 0, 1] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_rejectcollection-predicate_identity"></a>`_.reject(collection, [pred | <h3 id="_rejectcollection-predicate_identity"><code>_.reject(collection, [predic | |
icate=_.identity])` | ate=_.identity])</code></h3> | |
<a href="#_rejectcollection-predicate_identity">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9815 "View i | |
com/lodash/lodash/blob/4.0.0/lodash.js#L7873 "View in source") [Ⓣ][1] [&# | n source") [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm p | |
x24C3;](https://www.npmjs.com/package/lodash.reject "See the npm package") | ackage") [Ⓣ][1] | |
The opposite of `_.filter`; this method returns the elements of `collection` | The opposite of `_.filter`; this method returns the elements of `collection` | |
that `predicate` does **not** return truthy for. | that `predicate` does **not** return truthy for. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new filtered array. | *(Array)*: Returns the new filtered array. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'age': 36, 'active': false }, | { 'user': 'barney', 'age': 36, 'active': false }, | |
{ 'user': 'fred', 'age': 40, 'active': true } | { 'user': 'fred', 'age': 40, 'active': true } | |
]; | ]; | |
_.reject(users, function(o) { return !o.active; }); | _.reject(users, function(o) { return !o.active; }); | |
// => objects for ['fred'] | // => objects for ['fred'] | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.reject(users, { 'age': 40, 'active': true }); | _.reject(users, { 'age': 40, 'active': true }); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.reject(users, ['active', false]); | _.reject(users, ['active', false]); | |
// => objects for ['fred'] | // => objects for ['fred'] | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.reject(users, 'active'); | _.reject(users, 'active'); | |
// => objects for ['barney'] | // => objects for ['barney'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_samplecollection"></a>`_.sample(collection)` | <h3 id="_samplecollection"><code>_.sample(collection)</code></h3> | |
<a href="#_samplecollection">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9834 "View i | |
lob/4.0.0/lodash.js#L7894 "View in source") [Ⓣ][1] [Ⓝ](https://www | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm p | |
.npmjs.com/package/lodash.sample "See the npm package") | ackage") [Ⓣ][1] | |
Gets a random element from `collection`. | Gets a random element from `collection`. | |
#### Since | ||
2.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to sample. | 1. `collection` *(Array|Object)*: The collection to sample. | |
#### Returns | #### Returns | |
*(*)*: Returns the random element. | *(*)*: Returns the random element. | |
#### Example | #### Example | |
```js | ```js | |
_.sample([1, 2, 3, 4]); | _.sample([1, 2, 3, 4]); | |
// => 2 | // => 2 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_samplesizecollection-n0"></a>`_.sampleSize(collection, [n=0])` | <h3 id="_samplesizecollection-n1"><code>_.sampleSize(collection, [n=1])</code></ | |
<a href="#_samplesizecollection-n0">#</a> [Ⓢ](https://github.com/lodash/l | h3> | |
odash/blob/4.0.0/lodash.js#L7915 "View in source") [Ⓣ][1] [Ⓝ](http | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9859 "View i | |
s://www.npmjs.com/package/lodash.samplesize "See the npm package") | n source") [Ⓝ](https://www.npmjs.com/package/lodash.samplesize "See the n | |
pm package") [Ⓣ][1] | ||
Gets `n` random elements at unique keys from `collection` up to the | ||
size of `collection`. | ||
Gets `n` random elements from `collection`. | #### Since | |
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to sample. | 1. `collection` *(Array|Object)*: The collection to sample. | |
2. `[n=0]` *(number)*: The number of elements to sample. | 2. `[n=1]` *(number)*: The number of elements to sample. | |
#### Returns | #### Returns | |
*(Array)*: Returns the random elements. | *(Array)*: Returns the random elements. | |
#### Example | #### Example | |
```js | ```js | |
_.sampleSize([1, 2, 3, 4], 2); | _.sampleSize([1, 2, 3], 2); | |
// => [3, 1] | // => [3, 1] | |
_.sampleSize([1, 2, 3], 4); | ||
// => [2, 3, 1] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_shufflecollection"></a>`_.shuffle(collection)` | <h3 id="_shufflecollection"><code>_.shuffle(collection)</code></h3> | |
<a href="#_shufflecollection">#</a> [Ⓢ](https://github.com/lodash/lodash/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9884 "View i | |
blob/4.0.0/lodash.js#L7947 "View in source") [Ⓣ][1] [Ⓝ](https://ww | n source") [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm | |
w.npmjs.com/package/lodash.shuffle "See the npm package") | package") [Ⓣ][1] | |
Creates an array of shuffled values, using a version of the | Creates an array of shuffled values, using a version of the | |
[Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). | [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to shuffle. | 1. `collection` *(Array|Object)*: The collection to shuffle. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new shuffled array. | *(Array)*: Returns the new shuffled array. | |
#### Example | #### Example | |
```js | ```js | |
_.shuffle([1, 2, 3, 4]); | _.shuffle([1, 2, 3, 4]); | |
// => [4, 1, 3, 2] | // => [4, 1, 3, 2] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sizecollection"></a>`_.size(collection)` | <h3 id="_sizecollection"><code>_.size(collection)</code></h3> | |
<a href="#_sizecollection">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9910 "View i | |
b/4.0.0/lodash.js#L7971 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | n source") [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm pac | |
pmjs.com/package/lodash.size "See the npm package") | kage") [Ⓣ][1] | |
Gets the size of `collection` by returning its length for array-like | Gets the size of `collection` by returning its length for array-like | |
values or the number of own enumerable properties for objects. | values or the number of own enumerable string keyed properties for objects. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to inspect. | 1. `collection` *(Array|Object|string)*: The collection to inspect. | |
#### Returns | #### Returns | |
*(number)*: Returns the collection size. | *(number)*: Returns the collection size. | |
#### Example | #### Example | |
```js | ```js | |
_.size([1, 2, 3]); | _.size([1, 2, 3]); | |
// => 3 | // => 3 | |
_.size({ 'a': 1, 'b': 2 }); | _.size({ 'a': 1, 'b': 2 }); | |
// => 2 | // => 2 | |
_.size('pebbles'); | _.size('pebbles'); | |
// => 7 | // => 7 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_somecollection-predicate_identity"></a>`_.some(collection, [predicat | <h3 id="_somecollection-predicate_identity"><code>_.some(collection, [predicate= | |
e=_.identity])` | _.identity])</code></h3> | |
<a href="#_somecollection-predicate_identity">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9960 "View i | |
m/lodash/lodash/blob/4.0.0/lodash.js#L8016 "View in source") [Ⓣ][1] [ | n source") [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm pac | |
4C3;](https://www.npmjs.com/package/lodash.some "See the npm package") | kage") [Ⓣ][1] | |
Checks if `predicate` returns truthy for **any** element of `collection`. | Checks if `predicate` returns truthy for **any** element of `collection`. | |
Iteration is stopped once `predicate` returns truthy. The predicate is | Iteration is stopped once `predicate` returns truthy. The predicate is | |
invoked with three arguments: (value, index|key, collection). | invoked with three arguments: *(value, index|key, collection)*. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. | 2. `[predicate=_.identity]` *(Function)*: The function invoked per iteration. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if any element passes the predicate check, else `fa lse`. | *(boolean)*: Returns `true` if any element passes the predicate check, else `fal se`. | |
#### Example | #### Example | |
```js | ```js | |
_.some([null, 0, 'yes', false], Boolean); | _.some([null, 0, 'yes', false], Boolean); | |
// => true | // => true | |
var users = [ | var users = [ | |
{ 'user': 'barney', 'active': true }, | { 'user': 'barney', 'active': true }, | |
{ 'user': 'fred', 'active': false } | { 'user': 'fred', 'active': false } | |
]; | ]; | |
// using the `_.matches` iteratee shorthand | // The `_.matches` iteratee shorthand. | |
_.some(users, { 'user': 'barney', 'active': false }); | _.some(users, { 'user': 'barney', 'active': false }); | |
// => false | // => false | |
// using the `_.matchesProperty` iteratee shorthand | // The `_.matchesProperty` iteratee shorthand. | |
_.some(users, ['active', false]); | _.some(users, ['active', false]); | |
// => true | // => true | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.some(users, 'active'); | _.some(users, 'active'); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_sortbycollection-iteratees-_identity"></a>`_.sortBy(collection, [ite | <h3 id="_sortbycollection-iteratees_identity"><code>_.sortBy(collection, [iterat | |
ratees=[_.identity]])` | ees=[_.identity]])</code></h3> | |
<a href="#_sortbycollection-iteratees-_identity">#</a> [Ⓢ](https://github | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L9997 "View i | |
.com/lodash/lodash/blob/4.0.0/lodash.js#L8057 "View in source") [Ⓣ][1] [& | n source") [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm p | |
#x24C3;](https://www.npmjs.com/package/lodash.sortby "See the npm package") | ackage") [Ⓣ][1] | |
Creates an array of elements, sorted in ascending order by the results of | Creates an array of elements, sorted in ascending order by the results of | |
running each element in a collection through each iteratee. This method | running each element in a collection thru each iteratee. This method | |
performs a stable sort, that is, it preserves the original sort order of | performs a stable sort, that is, it preserves the original sort order of | |
equal elements. The iteratees are invoked with one argument: (value). | equal elements. The iteratees are invoked with one argument: *(value)*. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `collection` *(Array|Object)*: The collection to iterate over. | 1. `collection` *(Array|Object)*: The collection to iterate over. | |
2. `[iteratees=[_.identity]]` *(...(Function|Function[]|Object|Object	 1;]|string|string[])*: The iteratees to sort by, specified individu ally or in arrays. | 2. `[iteratees=[_.identity]]` *(...(Function|Function[]))*: The iteratee s to sort by. | |
#### Returns | #### Returns | |
*(Array)*: Returns the new sorted array. | *(Array)*: Returns the new sorted array. | |
#### Example | #### Example | |
```js | ```js | |
var users = [ | var users = [ | |
{ 'user': 'fred', 'age': 48 }, | { 'user': 'fred', 'age': 48 }, | |
{ 'user': 'barney', 'age': 36 }, | { 'user': 'barney', 'age': 36 }, | |
{ 'user': 'fred', 'age': 42 }, | { 'user': 'fred', 'age': 30 }, | |
{ 'user': 'barney', 'age': 34 } | { 'user': 'barney', 'age': 34 } | |
]; | ]; | |
_.sortBy(users, function(o) { return o.user; }); | _.sortBy(users, [function(o) { return o.user; }]); | |
// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] | // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] | |
_.sortBy(users, ['user', 'age']); | _.sortBy(users, ['user', 'age']); | |
// => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] | // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] | |
_.sortBy(users, 'user', function(o) { | ||
return Math.floor(o.age / 10); | ||
}); | ||
// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `“Date” Methods` | ## `“Date” Methods` | |
<!-- div --> | <!-- div --> | |
### <a id="_now"></a>`_.now()` | <h3 id="_now"><code>_.now()</code></h3> | |
<a href="#_now">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lod | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10028 "View | |
ash.js#L8088 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/pa | in source") [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm pac | |
ckage/lodash.now "See the npm package") | kage") [Ⓣ][1] | |
Gets the timestamp of the number of milliseconds that have elapsed since | Gets the timestamp of the number of milliseconds that have elapsed since | |
the Unix epoch (1 January 1970 00:00:00 UTC). | the Unix epoch *(1 January `1970 00`:00:00 UTC)*. | |
#### Since | ||
2.4.0 | ||
#### Returns | #### Returns | |
*(number)*: Returns the timestamp. | *(number)*: Returns the timestamp. | |
#### Example | #### Example | |
```js | ```js | |
_.defer(function(stamp) { | _.defer(function(stamp) { | |
console.log(_.now() - stamp); | console.log(_.now() - stamp); | |
}, _.now()); | }, _.now()); | |
// => logs the number of milliseconds it took for the deferred function to be in voked | // => Logs the number of milliseconds it took for the deferred invocation. | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `“Function” Methods` | ## `“Function” Methods` | |
<!-- div --> | <!-- div --> | |
### <a id="_aftern-func"></a>`_.after(n, func)` | <h3 id="_aftern-func"><code>_.after(n, func)</code></h3> | |
<a href="#_aftern-func">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10058 "View | |
.0.0/lodash.js#L8115 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmj | in source") [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm p | |
s.com/package/lodash.after "See the npm package") | ackage") [Ⓣ][1] | |
The opposite of `_.before`; this method creates a function that invokes | The opposite of `_.before`; this method creates a function that invokes | |
`func` once it's called `n` or more times. | `func` once it's called `n` or more times. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `n` *(number)*: The number of calls before `func` is invoked. | 1. `n` *(number)*: The number of calls before `func` is invoked. | |
2. `func` *(Function)*: The function to restrict. | 2. `func` *(Function)*: The function to restrict. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new restricted function. | *(Function)*: Returns the new restricted function. | |
#### Example | #### Example | |
```js | ```js | |
var saves = ['profile', 'settings']; | var saves = ['profile', 'settings']; | |
var done = _.after(saves.length, function() { | var done = _.after(saves.length, function() { | |
console.log('done saving!'); | console.log('done saving!'); | |
}); | }); | |
_.forEach(saves, function(type) { | _.forEach(saves, function(type) { | |
asyncSave({ 'type': type, 'complete': done }); | asyncSave({ 'type': type, 'complete': done }); | |
}); | }); | |
// => logs 'done saving!' after the two async saves have completed | // => Logs 'done saving!' after the two async saves have completed. | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_aryfunc-nfunclength"></a>`_.ary(func, [n=func.length])` | <h3 id="_aryfunc-nfunclength"><code>_.ary(func, [n=func.length])</code></h3> | |
<a href="#_aryfunc-nfunclength">#</a> [Ⓢ](https://github.com/lodash/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10087 "View | |
h/blob/4.0.0/lodash.js#L8143 "View in source") [Ⓣ][1] [Ⓝ](https:// | in source") [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm pac | |
www.npmjs.com/package/lodash.ary "See the npm package") | kage") [Ⓣ][1] | |
Creates a function that accepts up to `n` arguments, ignoring any | Creates a function that invokes `func`, with up to `n` arguments, | |
additional arguments. | ignoring any additional arguments. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to cap arguments for. | 1. `func` *(Function)*: The function to cap arguments for. | |
2. `[n=func.length]` *(number)*: The arity cap. | 2. `[n=func.length]` *(number)*: The arity cap. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new capped function. | |
#### Example | #### Example | |
```js | ```js | |
_.map(['6', '8', '10'], _.ary(parseInt, 1)); | _.map(['6', '8', '10'], _.ary(parseInt, 1)); | |
// => [6, 8, 10] | // => [6, 8, 10] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_beforen-func"></a>`_.before(n, func)` | <h3 id="_beforen-func"><code>_.before(n, func)</code></h3> | |
<a href="#_beforen-func">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10110 "View | |
4.0.0/lodash.js#L8165 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | in source") [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm | |
js.com/package/lodash.before "See the npm package") | package") [Ⓣ][1] | |
Creates a function that invokes `func`, with the `this` binding and arguments | Creates a function that invokes `func`, with the `this` binding and arguments | |
of the created function, while it's called less than `n` times. Subsequent | of the created function, while it's called less than `n` times. Subsequent | |
calls to the created function return the result of the last `func` invocation. | calls to the created function return the result of the last `func` invocation. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `n` *(number)*: The number of calls at which `func` is no longer invoked. | 1. `n` *(number)*: The number of calls at which `func` is no longer invoked. | |
2. `func` *(Function)*: The function to restrict. | 2. `func` *(Function)*: The function to restrict. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new restricted function. | *(Function)*: Returns the new restricted function. | |
#### Example | #### Example | |
```js | ```js | |
jQuery(element).on('click', _.before(5, addContactToList)); | jQuery(element).on('click', _.before(5, addContactToList)); | |
// => allows adding up to 4 contacts to the list | // => Allows adding up to 4 contacts to the list. | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_bindfunc-thisarg-partials"></a>`_.bind(func, thisArg, [partials])` | <h3 id="_bindfunc-thisarg-partials"><code>_.bind(func, thisArg, [partials])</cod | |
<a href="#_bindfunc-thisarg-partials">#</a> [Ⓢ](https://github.com/lodash | e></h3> | |
/lodash/blob/4.0.0/lodash.js#L8217 "View in source") [Ⓣ][1] [Ⓝ](ht | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10162 "View | |
tps://www.npmjs.com/package/lodash.bind "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm pa | |
ckage") [Ⓣ][1] | ||
Creates a function that invokes `func` with the `this` binding of `thisArg` | Creates a function that invokes `func` with the `this` binding of `thisArg` | |
and prepends any additional `_.bind` arguments to those provided to the | and `partials` prepended to the arguments it receives. | |
bound function. | ||
<br> | <br> | |
<br> | <br> | |
The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, | The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, | |
may be used as a placeholder for partially applied arguments. | may be used as a placeholder for partially applied arguments. | |
<br> | <br> | |
<br> | <br> | |
**Note:** Unlike native `Function#bind` this method doesn't set the "length" | **Note:** Unlike native `Function#bind`, this method doesn't set the "length" | |
property of bound functions. | property of bound functions. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to bind. | 1. `func` *(Function)*: The function to bind. | |
2. `thisArg` *(*)*: The `this` binding of `func`. | 2. `thisArg` *(*)*: The `this` binding of `func`. | |
3. `[partials]` *(...*)*: The arguments to be partially applied. | 3. `[partials]` *(...*)*: The arguments to be partially applied. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new bound function. | *(Function)*: Returns the new bound function. | |
#### Example | #### Example | |
```js | ```js | |
var greet = function(greeting, punctuation) { | function greet(greeting, punctuation) { | |
return greeting + ' ' + this.user + punctuation; | return greeting + ' ' + this.user + punctuation; | |
}; | } | |
var object = { 'user': 'fred' }; | var object = { 'user': 'fred' }; | |
var bound = _.bind(greet, object, 'hi'); | var bound = _.bind(greet, object, 'hi'); | |
bound('!'); | bound('!'); | |
// => 'hi fred!' | // => 'hi fred!' | |
// using placeholders | // Bound with placeholders. | |
var bound = _.bind(greet, object, _, '!'); | var bound = _.bind(greet, object, _, '!'); | |
bound('hi'); | bound('hi'); | |
// => 'hi fred!' | // => 'hi fred!' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_bindkeyobject-key-partials"></a>`_.bindKey(object, key, [partials])` | <h3 id="_bindkeyobject-key-partials"><code>_.bindKey(object, key, [partials])</c | |
<a href="#_bindkeyobject-key-partials">#</a> [Ⓢ](https://github.com/lodas | ode></h3> | |
h/lodash/blob/4.0.0/lodash.js#L8270 "View in source") [Ⓣ][1] [Ⓝ](h | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10216 "View | |
ttps://www.npmjs.com/package/lodash.bindkey "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm | |
package") [Ⓣ][1] | ||
Creates a function that invokes the method at `object[key]` and prepends | Creates a function that invokes the method at `object[key]` with `partials` | |
any additional `_.bindKey` arguments to those provided to the bound function. | prepended to the arguments it receives. | |
<br> | <br> | |
<br> | <br> | |
This method differs from `_.bind` by allowing bound functions to reference | This method differs from `_.bind` by allowing bound functions to reference | |
methods that may be redefined or don't yet exist. | methods that may be redefined or don't yet exist. See | |
See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-def | [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definit | |
inition-pattern) | ion-pattern) | |
for more details. | for more details. | |
<br> | <br> | |
<br> | <br> | |
The `_.bindKey.placeholder` value, which defaults to `_` in monolithic | The `_.bindKey.placeholder` value, which defaults to `_` in monolithic | |
builds, may be used as a placeholder for partially applied arguments. | builds, may be used as a placeholder for partially applied arguments. | |
#### Since | ||
0.10.0 | ||
#### Arguments | #### Arguments | |
1. `object` *(Object)*: The object to invoke the method on. | 1. `object` *(Object)*: The object to invoke the method on. | |
2. `key` *(string)*: The key of the method. | 2. `key` *(string)*: The key of the method. | |
3. `[partials]` *(...*)*: The arguments to be partially applied. | 3. `[partials]` *(...*)*: The arguments to be partially applied. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new bound function. | *(Function)*: Returns the new bound function. | |
#### Example | #### Example | |
```js | ```js | |
var object = { | var object = { | |
'user': 'fred', | 'user': 'fred', | |
'greet': function(greeting, punctuation) { | 'greet': function(greeting, punctuation) { | |
return greeting + ' ' + this.user + punctuation; | return greeting + ' ' + this.user + punctuation; | |
} | } | |
}; | }; | |
skipping to change at line 3169 | skipping to change at line 3709 | |
bound('!'); | bound('!'); | |
// => 'hi fred!' | // => 'hi fred!' | |
object.greet = function(greeting, punctuation) { | object.greet = function(greeting, punctuation) { | |
return greeting + 'ya ' + this.user + punctuation; | return greeting + 'ya ' + this.user + punctuation; | |
}; | }; | |
bound('!'); | bound('!'); | |
// => 'hiya fred!' | // => 'hiya fred!' | |
// using placeholders | // Bound with placeholders. | |
var bound = _.bindKey(object, 'greet', _, '!'); | var bound = _.bindKey(object, 'greet', _, '!'); | |
bound('hi'); | bound('hi'); | |
// => 'hiya fred!' | // => 'hiya fred!' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_curryfunc-arityfunclength"></a>`_.curry(func, [arity=func.length])` | <h3 id="_curryfunc-arityfunclength"><code>_.curry(func, [arity=func.length])</co | |
<a href="#_curryfunc-arityfunclength">#</a> [Ⓢ](https://github.com/lodash | de></h3> | |
/lodash/blob/4.0.0/lodash.js#L8319 "View in source") [Ⓣ][1] [Ⓝ](ht | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10266 "View | |
tps://www.npmjs.com/package/lodash.curry "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm p | |
ackage") [Ⓣ][1] | ||
Creates a function that accepts arguments of `func` and either invokes | Creates a function that accepts arguments of `func` and either invokes | |
`func` returning its result, if at least `arity` number of arguments have | `func` returning its result, if at least `arity` number of arguments have | |
been provided, or returns a function that accepts the remaining `func` | been provided, or returns a function that accepts the remaining `func` | |
arguments, and so on. The arity of `func` may be specified if `func.length` | arguments, and so on. The arity of `func` may be specified if `func.length` | |
is not sufficient. | is not sufficient. | |
<br> | <br> | |
<br> | <br> | |
The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, | The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, | |
may be used as a placeholder for provided arguments. | may be used as a placeholder for provided arguments. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method doesn't set the "length" property of curried functions. | **Note:** This method doesn't set the "length" property of curried functions. | |
#### Since | ||
2.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to curry. | 1. `func` *(Function)*: The function to curry. | |
2. `[arity=func.length]` *(number)*: The arity of `func`. | 2. `[arity=func.length]` *(number)*: The arity of `func`. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new curried function. | *(Function)*: Returns the new curried function. | |
#### Example | #### Example | |
```js | ```js | |
var abc = function(a, b, c) { | var abc = function(a, b, c) { | |
return [a, b, c]; | return [a, b, c]; | |
}; | }; | |
var curried = _.curry(abc); | var curried = _.curry(abc); | |
curried(1)(2)(3); | curried(1)(2)(3); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
curried(1, 2)(3); | curried(1, 2)(3); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
curried(1, 2, 3); | curried(1, 2, 3); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
// using placeholders | // Curried with placeholders. | |
curried(1)(_, 3)(2); | curried(1)(_, 3)(2); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_curryrightfunc-arityfunclength"></a>`_.curryRight(func, [arity=func. | <h3 id="_curryrightfunc-arityfunclength"><code>_.curryRight(func, [arity=func.le | |
length])` | ngth])</code></h3> | |
<a href="#_curryrightfunc-arityfunclength">#</a> [Ⓢ](https://github.com/l | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10311 "View | |
odash/lodash/blob/4.0.0/lodash.js#L8363 "View in source") [Ⓣ][1] [Ⓝ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the | |
;](https://www.npmjs.com/package/lodash.curryright "See the npm package") | npm package") [Ⓣ][1] | |
This method is like `_.curry` except that arguments are applied to `func` | This method is like `_.curry` except that arguments are applied to `func` | |
in the manner of `_.partialRight` instead of `_.partial`. | in the manner of `_.partialRight` instead of `_.partial`. | |
<br> | <br> | |
<br> | <br> | |
The `_.curryRight.placeholder` value, which defaults to `_` in monolithic | The `_.curryRight.placeholder` value, which defaults to `_` in monolithic | |
builds, may be used as a placeholder for provided arguments. | builds, may be used as a placeholder for provided arguments. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method doesn't set the "length" property of curried functions. | **Note:** This method doesn't set the "length" property of curried functions. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to curry. | 1. `func` *(Function)*: The function to curry. | |
2. `[arity=func.length]` *(number)*: The arity of `func`. | 2. `[arity=func.length]` *(number)*: The arity of `func`. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new curried function. | *(Function)*: Returns the new curried function. | |
#### Example | #### Example | |
```js | ```js | |
var abc = function(a, b, c) { | var abc = function(a, b, c) { | |
return [a, b, c]; | return [a, b, c]; | |
}; | }; | |
var curried = _.curryRight(abc); | var curried = _.curryRight(abc); | |
curried(3)(2)(1); | curried(3)(2)(1); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
curried(2, 3)(1); | curried(2, 3)(1); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
curried(1, 2, 3); | curried(1, 2, 3); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
// using placeholders | // Curried with placeholders. | |
curried(3)(1, _)(2); | curried(3)(1, _)(2); | |
// => [1, 2, 3] | // => [1, 2, 3] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_debouncefunc-wait0-options"></a>`_.debounce(func, [wait=0], [options | <h3 id="_debouncefunc-wait0-options"><code>_.debounce(func, [wait=0], [options={ | |
])` | }])</code></h3> | |
<a href="#_debouncefunc-wait0-options">#</a> [Ⓢ](https://github.com/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10372 "View | |
h/lodash/blob/4.0.0/lodash.js#L8419 "View in source") [Ⓣ][1] [Ⓝ](h | in source") [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the np | |
ttps://www.npmjs.com/package/lodash.debounce "See the npm package") | m package") [Ⓣ][1] | |
Creates a debounced function that delays invoking `func` until after `wait` | Creates a debounced function that delays invoking `func` until after `wait` | |
milliseconds have elapsed since the last time the debounced function was | milliseconds have elapsed since the last time the debounced function was | |
invoked. The debounced function comes with a `cancel` method to cancel | invoked. The debounced function comes with a `cancel` method to cancel | |
delayed `func` invocations and a `flush` method to immediately invoke them. | delayed `func` invocations and a `flush` method to immediately invoke them. | |
Provide an options object to indicate whether `func` should be invoked on | Provide `options` to indicate whether `func` should be invoked on the | |
the leading and/or trailing edge of the `wait` timeout. The `func` is invoked | leading and/or trailing edge of the `wait` timeout. The `func` is invoked | |
with the last arguments provided to the debounced function. Subsequent calls | with the last arguments provided to the debounced function. Subsequent | |
to the debounced function return the result of the last `func` invocation. | calls to the debounced function return the result of the last `func` | |
invocation. | ||
<br> | <br> | |
<br> | <br> | |
**Note:** If `leading` and `trailing` options are `true`, `func` is invoked | **Note:** If `leading` and `trailing` options are `true`, `func` is | |
on the trailing edge of the timeout only if the the debounced function is | invoked on the trailing edge of the timeout only if the debounced function | |
invoked more than once during the `wait` timeout. | is invoked more than once during the `wait` timeout. | |
<br> | <br> | |
<br> | <br> | |
See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-thro | If `wait` is `0` and `leading` is `false`, `func` invocation is deferred | |
ttle-visual-explanation) | until to the next tick, similar to `setTimeout` with a timeout of `0`. | |
<br> | ||
<br> | ||
See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-expl | ||
ained-examples/) | ||
for details over the differences between `_.debounce` and `_.throttle`. | for details over the differences between `_.debounce` and `_.throttle`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to debounce. | 1. `func` *(Function)*: The function to debounce. | |
2. `[wait=0]` *(number)*: The number of milliseconds to delay. | 2. `[wait=0]` *(number)*: The number of milliseconds to delay. | |
3. `[options]` *(Object)*: The options object. | 3. `[options={}]` *(Object)*: The options object. | |
4. `[options.leading=false]` *(boolean)*: Specify invoking on the leading edge o f the timeout. | 4. `[options.leading=false]` *(boolean)*: Specify invoking on the leading edge o f the timeout. | |
5. `[options.maxWait]` *(number)*: The maximum time `func` is allowed to be dela yed before it's invoked. | 5. `[options.maxWait]` *(number)*: The maximum time `func` is allowed to be dela yed before it's invoked. | |
6. `[options.trailing=true]` *(boolean)*: Specify invoking on the trailing edge of the timeout. | 6. `[options.trailing=true]` *(boolean)*: Specify invoking on the trailing edge of the timeout. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new debounced function. | *(Function)*: Returns the new debounced function. | |
#### Example | #### Example | |
```js | ```js | |
// avoid costly calculations while the window size is in flux | // Avoid costly calculations while the window size is in flux. | |
jQuery(window).on('resize', _.debounce(calculateLayout, 150)); | jQuery(window).on('resize', _.debounce(calculateLayout, 150)); | |
// invoke `sendMail` when clicked, debouncing subsequent calls | // Invoke `sendMail` when clicked, debouncing subsequent calls. | |
jQuery(element).on('click', _.debounce(sendMail, 300, { | jQuery(element).on('click', _.debounce(sendMail, 300, { | |
'leading': true, | 'leading': true, | |
'trailing': false | 'trailing': false | |
})); | })); | |
// ensure `batchLog` is invoked once after 1 second of debounced calls | // Ensure `batchLog` is invoked once after 1 second of debounced calls. | |
var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); | var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); | |
var source = new EventSource('/stream'); | var source = new EventSource('/stream'); | |
jQuery(source).on('message', debounced); | jQuery(source).on('message', debounced); | |
// cancel a trailing debounced invocation | // Cancel the trailing debounced invocation. | |
jQuery(window).on('popstate', debounced.cancel); | jQuery(window).on('popstate', debounced.cancel); | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_deferfunc-args"></a>`_.defer(func, [args])` | <h3 id="_deferfunc-args"><code>_.defer(func, [args])</code></h3> | |
<a href="#_deferfunc-args">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10515 "View | |
b/4.0.0/lodash.js#L8551 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm p | |
pmjs.com/package/lodash.defer "See the npm package") | ackage") [Ⓣ][1] | |
Defers invoking the `func` until the current call stack has cleared. Any | Defers invoking the `func` until the current call stack has cleared. Any | |
additional arguments are provided to `func` when it's invoked. | additional arguments are provided to `func` when it's invoked. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to defer. | 1. `func` *(Function)*: The function to defer. | |
2. `[args]` *(...*)*: The arguments to invoke `func` with. | 2. `[args]` *(...*)*: The arguments to invoke `func` with. | |
#### Returns | #### Returns | |
*(number)*: Returns the timer id. | *(number)*: Returns the timer id. | |
#### Example | #### Example | |
```js | ```js | |
_.defer(function(text) { | _.defer(function(text) { | |
console.log(text); | console.log(text); | |
}, 'deferred'); | }, 'deferred'); | |
// logs 'deferred' after one or more milliseconds | // => Logs 'deferred' after one millisecond. | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_delayfunc-wait-args"></a>`_.delay(func, wait, [args])` | <h3 id="_delayfunc-wait-args"><code>_.delay(func, wait, [args])</code></h3> | |
<a href="#_delayfunc-wait-args">#</a> [Ⓢ](https://github.com/lodash/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10538 "View | |
h/blob/4.0.0/lodash.js#L8573 "View in source") [Ⓣ][1] [Ⓝ](https:// | in source") [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm p | |
www.npmjs.com/package/lodash.delay "See the npm package") | ackage") [Ⓣ][1] | |
Invokes `func` after `wait` milliseconds. Any additional arguments are | Invokes `func` after `wait` milliseconds. Any additional arguments are | |
provided to `func` when it's invoked. | provided to `func` when it's invoked. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to delay. | 1. `func` *(Function)*: The function to delay. | |
2. `wait` *(number)*: The number of milliseconds to delay invocation. | 2. `wait` *(number)*: The number of milliseconds to delay invocation. | |
3. `[args]` *(...*)*: The arguments to invoke `func` with. | 3. `[args]` *(...*)*: The arguments to invoke `func` with. | |
#### Returns | #### Returns | |
*(number)*: Returns the timer id. | *(number)*: Returns the timer id. | |
#### Example | #### Example | |
```js | ```js | |
_.delay(function(text) { | _.delay(function(text) { | |
console.log(text); | console.log(text); | |
}, 1000, 'later'); | }, 1000, 'later'); | |
// => logs 'later' after one second | // => Logs 'later' after one second. | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_flipfunc"></a>`_.flip(func)` | <h3 id="_flipfunc"><code>_.flip(func)</code></h3> | |
<a href="#_flipfunc">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10560 "View | |
0/lodash.js#L8594 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.c | in source") [Ⓝ](https://www.npmjs.com/package/lodash.flip "See the npm pa | |
om/package/lodash.flip "See the npm package") | ckage") [Ⓣ][1] | |
Creates a function that invokes `func` with arguments reversed. | Creates a function that invokes `func` with arguments reversed. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to flip arguments for. | 1. `func` *(Function)*: The function to flip arguments for. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new flipped function. | |
#### Example | #### Example | |
```js | ```js | |
var flipped = _.flip(function() { | var flipped = _.flip(function() { | |
return _.toArray(arguments); | return _.toArray(arguments); | |
}); | }); | |
flipped('a', 'b', 'c', 'd'); | flipped('a', 'b', 'c', 'd'); | |
// => ['d', 'c', 'b', 'a'] | // => ['d', 'c', 'b', 'a'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_memoizefunc-resolver"></a>`_.memoize(func, [resolver])` | <h3 id="_memoizefunc-resolver"><code>_.memoize(func, [resolver])</code></h3> | |
<a href="#_memoizefunc-resolver">#</a> [Ⓢ](https://github.com/lodash/loda | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10608 "View | |
sh/blob/4.0.0/lodash.js#L8640 "View in source") [Ⓣ][1] [Ⓝ](https:/ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm | |
/www.npmjs.com/package/lodash.memoize "See the npm package") | package") [Ⓣ][1] | |
Creates a function that memoizes the result of `func`. If `resolver` is | Creates a function that memoizes the result of `func`. If `resolver` is | |
provided it determines the cache key for storing the result based on the | provided, it determines the cache key for storing the result based on the | |
arguments provided to the memoized function. By default, the first argument | arguments provided to the memoized function. By default, the first argument | |
provided to the memoized function is used as the map cache key. The `func` | provided to the memoized function is used as the map cache key. The `func` | |
is invoked with the `this` binding of the memoized function. | is invoked with the `this` binding of the memoized function. | |
<br> | <br> | |
<br> | <br> | |
**Note:** The cache is exposed as the `cache` property on the memoized | **Note:** The cache is exposed as the `cache` property on the memoized | |
function. Its creation may be customized by replacing the `_.memoize.Cache` | function. Its creation may be customized by replacing the `_.memoize.Cache` | |
constructor with one whose instances implement the [`Map`](http://ecma-internati | constructor with one whose instances implement the | |
onal.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) | [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-pr | |
method interface of `delete`, `get`, `has`, and `set`. | ototype-object) | |
method interface of `clear`, `delete`, `get`, `has`, and `set`. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to have its output memoized. | 1. `func` *(Function)*: The function to have its output memoized. | |
2. `[resolver]` *(Function)*: The function to resolve the cache key. | 2. `[resolver]` *(Function)*: The function to resolve the cache key. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new memoizing function. | *(Function)*: Returns the new memoized function. | |
#### Example | #### Example | |
```js | ```js | |
var object = { 'a': 1, 'b': 2 }; | var object = { 'a': 1, 'b': 2 }; | |
var other = { 'c': 3, 'd': 4 }; | var other = { 'c': 3, 'd': 4 }; | |
var values = _.memoize(_.values); | var values = _.memoize(_.values); | |
values(object); | values(object); | |
// => [1, 2] | // => [1, 2] | |
values(other); | values(other); | |
// => [3, 4] | // => [3, 4] | |
object.a = 2; | object.a = 2; | |
values(object); | values(object); | |
// => [1, 2] | // => [1, 2] | |
// modifying the result cache | // Modify the result cache. | |
values.cache.set(object, ['a', 'b']); | values.cache.set(object, ['a', 'b']); | |
values(object); | values(object); | |
// => ['a', 'b'] | // => ['a', 'b'] | |
// replacing `_.memoize.Cache` | // Replace `_.memoize.Cache`. | |
_.memoize.Cache = WeakMap; | _.memoize.Cache = WeakMap; | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_negatepredicate"></a>`_.negate(predicate)` | <h3 id="_negatepredicate"><code>_.negate(predicate)</code></h3> | |
<a href="#_negatepredicate">#</a> [Ⓢ](https://github.com/lodash/lodash/bl | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10651 "View | |
ob/4.0.0/lodash.js#L8679 "View in source") [Ⓣ][1] [Ⓝ](https://www. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm | |
npmjs.com/package/lodash.negate "See the npm package") | package") [Ⓣ][1] | |
Creates a function that negates the result of the predicate `func`. The | Creates a function that negates the result of the predicate `func`. The | |
`func` predicate is invoked with the `this` binding and arguments of the | `func` predicate is invoked with the `this` binding and arguments of the | |
created function. | created function. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `predicate` *(Function)*: The predicate to negate. | 1. `predicate` *(Function)*: The predicate to negate. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new negated function. | |
#### Example | #### Example | |
```js | ```js | |
function isEven(n) { | function isEven(n) { | |
return n % 2 == 0; | return n % 2 == 0; | |
} | } | |
_.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); | _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); | |
// => [1, 3, 5] | // => [1, 3, 5] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_oncefunc"></a>`_.once(func)` | <h3 id="_oncefunc"><code>_.once(func)</code></h3> | |
<a href="#_oncefunc">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10685 "View | |
0/lodash.js#L8705 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.c | in source") [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm pa | |
om/package/lodash.once "See the npm package") | ckage") [Ⓣ][1] | |
Creates a function that is restricted to invoking `func` once. Repeat calls | Creates a function that is restricted to invoking `func` once. Repeat calls | |
to the function return the value of the first invocation. The `func` is | to the function return the value of the first invocation. The `func` is | |
invoked with the `this` binding and arguments of the created function. | invoked with the `this` binding and arguments of the created function. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to restrict. | 1. `func` *(Function)*: The function to restrict. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new restricted function. | *(Function)*: Returns the new restricted function. | |
#### Example | #### Example | |
```js | ```js | |
var initialize = _.once(createApplication); | var initialize = _.once(createApplication); | |
initialize(); | initialize(); | |
initialize(); | initialize(); | |
// `initialize` invokes `createApplication` once | // => `createApplication` is invoked once | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_overargsfunc-transforms"></a>`_.overArgs(func, [transforms])` | <h3 id="_overargsfunc-transforms_identity"><code>_.overArgs(func, [transforms=[_ | |
<a href="#_overargsfunc-transforms">#</a> [Ⓢ](https://github.com/lodash/l | .identity]])</code></h3> | |
odash/blob/4.0.0/lodash.js#L8740 "View in source") [Ⓣ][1] [Ⓝ](http | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10720 "View | |
s://www.npmjs.com/package/lodash.overargs "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.overargs "See the np | |
m package") [Ⓣ][1] | ||
Creates a function that invokes `func` with arguments transformed by | Creates a function that invokes `func` with its arguments transformed. | |
corresponding `transforms`. | ||
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to wrap. | 1. `func` *(Function)*: The function to wrap. | |
2. `[transforms]` *(...(Function|Function[])*: The functions to transfor m arguments, specified individually or in arrays. | 2. `[transforms=[_.identity]]` *(...(Function|Function[]))*: The argumen t transforms. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new function. | |
#### Example | #### Example | |
```js | ```js | |
function doubled(n) { | function doubled(n) { | |
return n * 2; | return n * 2; | |
} | } | |
function square(n) { | function square(n) { | |
return n * n; | return n * n; | |
} | } | |
var func = _.overArgs(function(x, y) { | var func = _.overArgs(function(x, y) { | |
return [x, y]; | return [x, y]; | |
}, square, doubled); | }, [square, doubled]); | |
func(9, 3); | func(9, 3); | |
// => [81, 6] | // => [81, 6] | |
func(10, 5); | func(10, 5); | |
// => [100, 10] | // => [100, 10] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_partialfunc-partials"></a>`_.partial(func, [partials])` | <h3 id="_partialfunc-partials"><code>_.partial(func, [partials])</code></h3> | |
<a href="#_partialfunc-partials">#</a> [Ⓢ](https://github.com/lodash/loda | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10770 "View | |
sh/blob/4.0.0/lodash.js#L8787 "View in source") [Ⓣ][1] [Ⓝ](https:/ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm | |
/www.npmjs.com/package/lodash.partial "See the npm package") | package") [Ⓣ][1] | |
Creates a function that invokes `func` with `partial` arguments prepended | Creates a function that invokes `func` with `partials` prepended to the | |
to those provided to the new function. This method is like `_.bind` except | arguments it receives. This method is like `_.bind` except it does **not** | |
it does **not** alter the `this` binding. | alter the `this` binding. | |
<br> | <br> | |
<br> | <br> | |
The `_.partial.placeholder` value, which defaults to `_` in monolithic | The `_.partial.placeholder` value, which defaults to `_` in monolithic | |
builds, may be used as a placeholder for partially applied arguments. | builds, may be used as a placeholder for partially applied arguments. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method doesn't set the "length" property of partially | **Note:** This method doesn't set the "length" property of partially | |
applied functions. | applied functions. | |
#### Since | ||
0.2.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to partially apply arguments to. | 1. `func` *(Function)*: The function to partially apply arguments to. | |
2. `[partials]` *(...*)*: The arguments to be partially applied. | 2. `[partials]` *(...*)*: The arguments to be partially applied. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new partially applied function. | *(Function)*: Returns the new partially applied function. | |
#### Example | #### Example | |
```js | ```js | |
var greet = function(greeting, name) { | function greet(greeting, name) { | |
return greeting + ' ' + name; | return greeting + ' ' + name; | |
}; | } | |
var sayHelloTo = _.partial(greet, 'hello'); | var sayHelloTo = _.partial(greet, 'hello'); | |
sayHelloTo('fred'); | sayHelloTo('fred'); | |
// => 'hello fred' | // => 'hello fred' | |
// using placeholders | // Partially applied with placeholders. | |
var greetFred = _.partial(greet, _, 'fred'); | var greetFred = _.partial(greet, _, 'fred'); | |
greetFred('hi'); | greetFred('hi'); | |
// => 'hi fred' | // => 'hi fred' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_partialrightfunc-partials"></a>`_.partialRight(func, [partials])` | <h3 id="_partialrightfunc-partials"><code>_.partialRight(func, [partials])</code | |
<a href="#_partialrightfunc-partials">#</a> [Ⓢ](https://github.com/lodash | ></h3> | |
/lodash/blob/4.0.0/lodash.js#L8823 "View in source") [Ⓣ][1] [Ⓝ](ht | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10807 "View | |
tps://www.npmjs.com/package/lodash.partialright "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See th | |
e npm package") [Ⓣ][1] | ||
This method is like `_.partial` except that partially applied arguments | This method is like `_.partial` except that partially applied arguments | |
are appended to those provided to the new function. | are appended to the arguments it receives. | |
<br> | <br> | |
<br> | <br> | |
The `_.partialRight.placeholder` value, which defaults to `_` in monolithic | The `_.partialRight.placeholder` value, which defaults to `_` in monolithic | |
builds, may be used as a placeholder for partially applied arguments. | builds, may be used as a placeholder for partially applied arguments. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method doesn't set the "length" property of partially | **Note:** This method doesn't set the "length" property of partially | |
applied functions. | applied functions. | |
#### Since | ||
1.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to partially apply arguments to. | 1. `func` *(Function)*: The function to partially apply arguments to. | |
2. `[partials]` *(...*)*: The arguments to be partially applied. | 2. `[partials]` *(...*)*: The arguments to be partially applied. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new partially applied function. | *(Function)*: Returns the new partially applied function. | |
#### Example | #### Example | |
```js | ```js | |
var greet = function(greeting, name) { | function greet(greeting, name) { | |
return greeting + ' ' + name; | return greeting + ' ' + name; | |
}; | } | |
var greetFred = _.partialRight(greet, 'fred'); | var greetFred = _.partialRight(greet, 'fred'); | |
greetFred('hi'); | greetFred('hi'); | |
// => 'hi fred' | // => 'hi fred' | |
// using placeholders | // Partially applied with placeholders. | |
var sayHelloTo = _.partialRight(greet, 'hello', _); | var sayHelloTo = _.partialRight(greet, 'hello', _); | |
sayHelloTo('fred'); | sayHelloTo('fred'); | |
// => 'hello fred' | // => 'hello fred' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_reargfunc-indexes"></a>`_.rearg(func, indexes)` | <h3 id="_reargfunc-indexes"><code>_.rearg(func, indexes)</code></h3> | |
<a href="#_reargfunc-indexes">#</a> [Ⓢ](https://github.com/lodash/lodash/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10834 "View | |
blob/4.0.0/lodash.js#L8850 "View in source") [Ⓣ][1] [Ⓝ](https://ww | in source") [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm p | |
w.npmjs.com/package/lodash.rearg "See the npm package") | ackage") [Ⓣ][1] | |
Creates a function that invokes `func` with arguments arranged according | Creates a function that invokes `func` with arguments arranged according | |
to the specified indexes where the argument value at the first index is | to the specified `indexes` where the argument value at the first index is | |
provided as the first argument, the argument value at the second index is | provided as the first argument, the argument value at the second index is | |
provided as the second argument, and so on. | provided as the second argument, and so on. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to rearrange arguments for. | 1. `func` *(Function)*: The function to rearrange arguments for. | |
2. `indexes` *(...(number|number[])*: The arranged argument indexes, spe cified individually or in arrays. | 2. `indexes` *(...(number|number[]))*: The arranged argument indexes. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new function. | |
#### Example | #### Example | |
```js | ```js | |
var rearged = _.rearg(function(a, b, c) { | var rearged = _.rearg(function(a, b, c) { | |
return [a, b, c]; | return [a, b, c]; | |
}, 2, 0, 1); | }, [2, 0, 1]); | |
rearged('b', 'c', 'a') | rearged('b', 'c', 'a') | |
// => ['a', 'b', 'c'] | // => ['a', 'b', 'c'] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_restfunc-startfunclength-1"></a>`_.rest(func, [start=func.length-1]) | <h3 id="_restfunc-startfunclength-1"><code>_.rest(func, [start=func.length-1])</ | |
` | code></h3> | |
<a href="#_restfunc-startfunclength-1">#</a> [Ⓢ](https://github.com/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10863 "View | |
h/lodash/blob/4.0.0/lodash.js#L8876 "View in source") [Ⓣ][1] [Ⓝ](h | in source") [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm pa | |
ttps://www.npmjs.com/package/lodash.rest "See the npm package") | ckage") [Ⓣ][1] | |
Creates a function that invokes `func` with the `this` binding of the | Creates a function that invokes `func` with the `this` binding of the | |
created function and arguments from `start` and beyond provided as an array. | created function and arguments from `start` and beyond provided as | |
an array. | ||
<br> | <br> | |
<br> | <br> | |
**Note:** This method is based on the [rest parameter](https://mdn.io/rest_param | **Note:** This method is based on the | |
eters). | [rest parameter](https://mdn.io/rest_parameters). | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to apply a rest parameter to. | 1. `func` *(Function)*: The function to apply a rest parameter to. | |
2. `[start=func.length-1]` *(number)*: The start position of the rest parameter. | 2. `[start=func.length-1]` *(number)*: The start position of the rest parameter. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new function. | |
#### Example | #### Example | |
```js | ```js | |
var say = _.rest(function(what, names) { | var say = _.rest(function(what, names) { | |
return what + ' ' + _.initial(names).join(', ') + | return what + ' ' + _.initial(names).join(', ') + | |
(_.size(names) > 1 ? ', & ' : '') + _.last(names); | (_.size(names) > 1 ? ', & ' : '') + _.last(names); | |
}); | }); | |
say('hello', 'fred', 'barney', 'pebbles'); | say('hello', 'fred', 'barney', 'pebbles'); | |
// => 'hello fred, barney, & pebbles' | // => 'hello fred, barney, & pebbles' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_spreadfunc"></a>`_.spread(func)` | <h3 id="_spreadfunc-start0"><code>_.spread(func, [start=0])</code></h3> | |
<a href="#_spreadfunc">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10905 "View | |
0.0/lodash.js#L8936 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs | in source") [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm | |
.com/package/lodash.spread "See the npm package") | package") [Ⓣ][1] | |
Creates a function that invokes `func` with the `this` binding of the created | Creates a function that invokes `func` with the `this` binding of the | |
function and an array of arguments much like [`Function#apply`](https://es5.gith | create function and an array of arguments much like | |
ub.io/#x15.3.4.3). | [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function. | |
prototype.apply). | ||
<br> | <br> | |
<br> | <br> | |
**Note:** This method is based on the [spread operator](https://mdn.io/spread_op | **Note:** This method is based on the | |
erator). | [spread operator](https://mdn.io/spread_operator). | |
#### Since | ||
3.2.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to spread arguments over. | 1. `func` *(Function)*: The function to spread arguments over. | |
2. `[start=0]` *(number)*: The start position of the spread. | ||
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new function. | |
#### Example | #### Example | |
```js | ```js | |
var say = _.spread(function(who, what) { | var say = _.spread(function(who, what) { | |
return who + ' says ' + what; | return who + ' says ' + what; | |
}); | }); | |
say(['fred', 'hello']); | say(['fred', 'hello']); | |
// => 'fred says hello' | // => 'fred says hello' | |
// with a Promise | ||
var numbers = Promise.all([ | var numbers = Promise.all([ | |
Promise.resolve(40), | Promise.resolve(40), | |
Promise.resolve(36) | Promise.resolve(36) | |
]); | ]); | |
numbers.then(_.spread(function(x, y) { | numbers.then(_.spread(function(x, y) { | |
return x + y; | return x + y; | |
})); | })); | |
// => a Promise of 76 | // => a Promise of 76 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_throttlefunc-wait0-options"></a>`_.throttle(func, [wait=0], [options | <h3 id="_throttlefunc-wait0-options"><code>_.throttle(func, [wait=0], [options={ | |
])` | }])</code></h3> | |
<a href="#_throttlefunc-wait0-options">#</a> [Ⓢ](https://github.com/lodas | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10965 "View | |
h/lodash/blob/4.0.0/lodash.js#L8985 "View in source") [Ⓣ][1] [Ⓝ](h | in source") [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the np | |
ttps://www.npmjs.com/package/lodash.throttle "See the npm package") | m package") [Ⓣ][1] | |
Creates a throttled function that only invokes `func` at most once per | Creates a throttled function that only invokes `func` at most once per | |
every `wait` milliseconds. The throttled function comes with a `cancel` | every `wait` milliseconds. The throttled function comes with a `cancel` | |
method to cancel delayed `func` invocations and a `flush` method to | method to cancel delayed `func` invocations and a `flush` method to | |
immediately invoke them. Provide an options object to indicate whether | immediately invoke them. Provide `options` to indicate whether `func` | |
`func` should be invoked on the leading and/or trailing edge of the `wait` | should be invoked on the leading and/or trailing edge of the `wait` | |
timeout. The `func` is invoked with the last arguments provided to the | timeout. The `func` is invoked with the last arguments provided to the | |
throttled function. Subsequent calls to the throttled function return the | throttled function. Subsequent calls to the throttled function return the | |
result of the last `func` invocation. | result of the last `func` invocation. | |
<br> | <br> | |
<br> | <br> | |
**Note:** If `leading` and `trailing` options are `true`, `func` is invoked | **Note:** If `leading` and `trailing` options are `true`, `func` is | |
on the trailing edge of the timeout only if the the throttled function is | invoked on the trailing edge of the timeout only if the throttled function | |
invoked more than once during the `wait` timeout. | is invoked more than once during the `wait` timeout. | |
<br> | ||
<br> | ||
If `wait` is `0` and `leading` is `false`, `func` invocation is deferred | ||
until to the next tick, similar to `setTimeout` with a timeout of `0`. | ||
<br> | <br> | |
<br> | <br> | |
See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-thro ttle-visual-explanation) | See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-expl ained-examples/) | |
for details over the differences between `_.throttle` and `_.debounce`. | for details over the differences between `_.throttle` and `_.debounce`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to throttle. | 1. `func` *(Function)*: The function to throttle. | |
2. `[wait=0]` *(number)*: The number of milliseconds to throttle invocations to. | 2. `[wait=0]` *(number)*: The number of milliseconds to throttle invocations to. | |
3. `[options]` *(Object)*: The options object. | 3. `[options={}]` *(Object)*: The options object. | |
4. `[options.leading=true]` *(boolean)*: Specify invoking on the leading edge of the timeout. | 4. `[options.leading=true]` *(boolean)*: Specify invoking on the leading edge of the timeout. | |
5. `[options.trailing=true]` *(boolean)*: Specify invoking on the trailing edge of the timeout. | 5. `[options.trailing=true]` *(boolean)*: Specify invoking on the trailing edge of the timeout. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new throttled function. | *(Function)*: Returns the new throttled function. | |
#### Example | #### Example | |
```js | ```js | |
// avoid excessively updating the position while scrolling | // Avoid excessively updating the position while scrolling. | |
jQuery(window).on('scroll', _.throttle(updatePosition, 100)); | jQuery(window).on('scroll', _.throttle(updatePosition, 100)); | |
// invoke `renewToken` when the click event is fired, but not more than once eve ry 5 minutes | // Invoke `renewToken` when the click event is fired, but not more than once eve ry 5 minutes. | |
var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); | var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); | |
jQuery(element).on('click', throttled); | jQuery(element).on('click', throttled); | |
// cancel a trailing throttled invocation | // Cancel the trailing throttled invocation. | |
jQuery(window).on('popstate', throttled.cancel); | jQuery(window).on('popstate', throttled.cancel); | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_unaryfunc"></a>`_.unary(func)` | <h3 id="_unaryfunc"><code>_.unary(func)</code></h3> | |
<a href="#_unaryfunc">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L10998 "View | |
.0/lodash.js#L9013 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.unary "See the npm p | |
com/package/lodash.unary "See the npm package") | ackage") [Ⓣ][1] | |
Creates a function that accepts up to one argument, ignoring any | Creates a function that accepts up to one argument, ignoring any | |
additional arguments. | additional arguments. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `func` *(Function)*: The function to cap arguments for. | 1. `func` *(Function)*: The function to cap arguments for. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new capped function. | |
#### Example | #### Example | |
```js | ```js | |
_.map(['6', '8', '10'], _.unary(parseInt)); | _.map(['6', '8', '10'], _.unary(parseInt)); | |
// => [6, 8, 10] | // => [6, 8, 10] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_wrapvalue-wrapper"></a>`_.wrap(value, wrapper)` | <h3 id="_wrapvalue-wrapperidentity"><code>_.wrap(value, [wrapper=identity])</cod | |
<a href="#_wrapvalue-wrapper">#</a> [Ⓢ](https://github.com/lodash/lodash/ | e></h3> | |
blob/4.0.0/lodash.js#L9038 "View in source") [Ⓣ][1] [Ⓝ](https://ww | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11024 "View | |
w.npmjs.com/package/lodash.wrap "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm pa | |
ckage") [Ⓣ][1] | ||
Creates a function that provides `value` to `wrapper` as its first | ||
argument. Any additional arguments provided to the function are appended | ||
to those provided to the `wrapper`. The wrapper is invoked with the `this` | ||
binding of the created function. | ||
Creates a function that provides `value` to the wrapper function as its | #### Since | |
first argument. Any additional arguments provided to the function are | 0.1.0 | |
appended to those provided to the wrapper function. The wrapper is invoked | ||
with the `this` binding of the created function. | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to wrap. | 1. `value` *(*)*: The value to wrap. | |
2. `wrapper` *(Function)*: The wrapper function. | 2. `[wrapper=identity]` *(Function)*: The wrapper function. | |
#### Returns | #### Returns | |
*(Function)*: Returns the new function. | *(Function)*: Returns the new function. | |
#### Example | #### Example | |
```js | ```js | |
var p = _.wrap(_.escape, function(func, text) { | var p = _.wrap(_.escape, function(func, text) { | |
return '<p>' + func(text) + '</p>'; | return '<p>' + func(text) + '</p>'; | |
}); | }); | |
p('fred, barney, & pebbles'); | p('fred, barney, & pebbles'); | |
// => '<p>fred, barney, & pebbles</p>' | // => '<p>fred, barney, & pebbles</p>' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `“Lang” Methods` | ## `“Lang” Methods` | |
<!-- div --> | <!-- div --> | |
### <a id="_clonevalue"></a>`_.clone(value)` | <h3 id="_castarrayvalue"><code>_.castArray(value)</code></h3> | |
<a href="#_clonevalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11063 "View | |
0.0/lodash.js#L9069 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs | in source") [Ⓝ](https://www.npmjs.com/package/lodash.castarray "See the n | |
.com/package/lodash.clone "See the npm package") | pm package") [Ⓣ][1] | |
Casts `value` as an array if it's not one. | ||
#### Since | ||
4.4.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to inspect. | ||
#### Returns | ||
*(Array)*: Returns the cast array. | ||
#### Example | ||
```js | ||
_.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 | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_clonevalue"><code>_.clone(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11097 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm p | ||
ackage") [Ⓣ][1] | ||
Creates a shallow clone of `value`. | Creates a shallow clone of `value`. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is loosely based on the | **Note:** This method is loosely based on the | |
[structured clone algorithm](https://mdn.io/Structured_clone_algorithm) | [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) | |
and supports cloning arrays, array buffers, booleans, date objects, maps, | and supports cloning arrays, array buffers, booleans, date objects, maps, | |
numbers, `Object` objects, regexes, sets, strings, symbols, and typed | numbers, `Object` objects, regexes, sets, strings, symbols, and typed | |
arrays. The own enumerable properties of `arguments` objects are cloned | arrays. The own enumerable properties of `arguments` objects are cloned | |
as plain objects. An empty object is returned for uncloneable values such | as plain objects. An empty object is returned for uncloneable values such | |
as error objects, functions, DOM nodes, and WeakMaps. | as error objects, functions, DOM nodes, and WeakMaps. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to clone. | 1. `value` *(*)*: The value to clone. | |
#### Returns | #### Returns | |
*(*)*: Returns the cloned value. | *(*)*: Returns the cloned value. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'a': 1 }, { 'b': 2 }]; | var objects = [{ 'a': 1 }, { 'b': 2 }]; | |
var shallow = _.clone(objects); | var shallow = _.clone(objects); | |
console.log(shallow[0] === objects[0]); | console.log(shallow[0] === objects[0]); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_clonedeepvalue"></a>`_.cloneDeep(value)` | <h3 id="_clonedeepvalue"><code>_.cloneDeep(value)</code></h3> | |
<a href="#_clonedeepvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11155 "View | |
b/4.0.0/lodash.js#L9122 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the n | |
pmjs.com/package/lodash.clonedeep "See the npm package") | pm package") [Ⓣ][1] | |
This method is like `_.clone` except that it recursively clones `value`. | This method is like `_.clone` except that it recursively clones `value`. | |
#### Since | ||
1.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to recursively clone. | 1. `value` *(*)*: The value to recursively clone. | |
#### Returns | #### Returns | |
*(*)*: Returns the deep cloned value. | *(*)*: Returns the deep cloned value. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'a': 1 }, { 'b': 2 }]; | var objects = [{ 'a': 1 }, { 'b': 2 }]; | |
var deep = _.cloneDeep(objects); | var deep = _.cloneDeep(objects); | |
console.log(deep[0] === objects[0]); | console.log(deep[0] === objects[0]); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_clonedeepwithvalue-customizer"></a>`_.cloneDeepWith(value, [customiz | <h3 id="_clonedeepwithvalue-customizer"><code>_.cloneDeepWith(value, [customizer | |
er])` | ])</code></h3> | |
<a href="#_clonedeepwithvalue-customizer">#</a> [Ⓢ](https://github.com/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11187 "View | |
dash/lodash/blob/4.0.0/lodash.js#L9152 "View in source") [Ⓣ][1] [Ⓝ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.clonedeepwith "See t | |
](https://www.npmjs.com/package/lodash.clonedeepwith "See the npm package") | he npm package") [Ⓣ][1] | |
This method is like `_.cloneWith` except that it recursively clones `value`. | This method is like `_.cloneWith` except that it recursively clones `value`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to recursively clone. | 1. `value` *(*)*: The value to recursively clone. | |
2. `[customizer]` *(Function)*: The function to customize cloning. | 2. `[customizer]` *(Function)*: The function to customize cloning. | |
#### Returns | #### Returns | |
*(*)*: Returns the deep cloned value. | *(*)*: Returns the deep cloned value. | |
#### Example | #### Example | |
```js | ```js | |
function customizer(value) { | function customizer(value) { | |
if (_.isElement(value)) { | if (_.isElement(value)) { | |
return value.cloneNode(true); | return value.cloneNode(true); | |
} | } | |
} | } | |
var el = _.cloneDeep(document.body, customizer); | var el = _.cloneDeepWith(document.body, customizer); | |
console.log(el === document.body); | console.log(el === document.body); | |
// => false | // => false | |
console.log(el.nodeName); | console.log(el.nodeName); | |
// => 'BODY' | // => 'BODY' | |
console.log(el.childNodes.length); | console.log(el.childNodes.length); | |
// => 20 | // => 20 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_clonewithvalue-customizer"></a>`_.cloneWith(value, [customizer])` | <h3 id="_clonewithvalue-customizer"><code>_.cloneWith(value, [customizer])</code | |
<a href="#_clonewithvalue-customizer">#</a> [Ⓢ](https://github.com/lodash | ></h3> | |
/lodash/blob/4.0.0/lodash.js#L9102 "View in source") [Ⓣ][1] [Ⓝ](ht | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11132 "View | |
tps://www.npmjs.com/package/lodash.clonewith "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.clonewith "See the n | |
pm package") [Ⓣ][1] | ||
This method is like `_.clone` except that it accepts `customizer` which | This method is like `_.clone` except that it accepts `customizer` which | |
is invoked to produce the cloned value. If `customizer` returns `undefined` | is invoked to produce the cloned value. If `customizer` returns `undefined`, | |
cloning is handled by the method instead. The `customizer` is invoked with | cloning is handled by the method instead. The `customizer` is invoked with | |
up to five arguments; (value [, index|key, object, stack]). | up to four arguments; *(value [, index|key, object, stack])*. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to clone. | 1. `value` *(*)*: The value to clone. | |
2. `[customizer]` *(Function)*: The function to customize cloning. | 2. `[customizer]` *(Function)*: The function to customize cloning. | |
#### Returns | #### Returns | |
*(*)*: Returns the cloned value. | *(*)*: Returns the cloned value. | |
#### Example | #### Example | |
```js | ```js | |
function customizer(value) { | function customizer(value) { | |
if (_.isElement(value)) { | if (_.isElement(value)) { | |
return value.cloneNode(false); | return value.cloneNode(false); | |
} | } | |
} | } | |
var el = _.clone(document.body, customizer); | var el = _.cloneWith(document.body, customizer); | |
console.log(el === document.body); | console.log(el === document.body); | |
// => false | // => false | |
console.log(el.nodeName); | console.log(el.nodeName); | |
// => 'BODY' | // => 'BODY' | |
console.log(el.childNodes.length); | console.log(el.childNodes.length); | |
// => 0 | // => 0 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_eqvalue-other"></a>`_.eq(value, other)` | <h3 id="_conformstoobject-source"><code>_.conformsTo(object, source)</code></h3> | |
<a href="#_eqvalue-other">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11216 "View | |
/4.0.0/lodash.js#L9186 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.conformsto "See the | |
mjs.com/package/lodash.eq "See the npm package") | npm package") [Ⓣ][1] | |
Checks if `object` conforms to `source` by invoking the predicate | ||
properties of `source` with the corresponding property values of `object`. | ||
<br> | ||
<br> | ||
**Note:** This method is equivalent to `_.conforms` when `source` is | ||
partially applied. | ||
#### Since | ||
4.14.0 | ||
#### Arguments | ||
1. `object` *(Object)*: The object to inspect. | ||
2. `source` *(Object)*: The object of property predicates to conform to. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `object` conforms, else `false`. | ||
#### Example | ||
```js | ||
var object = { 'a': 1, 'b': 2 }; | ||
_.conformsTo(object, { 'b': function(n) { return n > 1; } }); | ||
// => true | ||
_.conformsTo(object, { 'b': function(n) { return n > 2; } }); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | ||
Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-sam | <!-- div --> | |
evaluezero) | ||
<h3 id="_eqvalue-other"><code>_.eq(value, other)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11252 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.eq "See the npm pack | ||
age") [Ⓣ][1] | ||
Performs a | ||
[`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | ||
comparison between two values to determine if they are equivalent. | comparison between two values to determine if they are equivalent. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if the values are equivalent, else `false`. | *(boolean)*: Returns `true` if the values are equivalent, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
var object = { 'user': 'fred' }; | var object = { 'a': 1 }; | |
var other = { 'user': 'fred' }; | var other = { 'a': 1 }; | |
_.eq(object, object); | _.eq(object, object); | |
// => true | // => true | |
_.eq(object, other); | _.eq(object, other); | |
// => false | // => false | |
_.eq('a', 'a'); | _.eq('a', 'a'); | |
// => true | // => true | |
_.eq('a', Object('a')); | _.eq('a', Object('a')); | |
// => false | // => false | |
_.eq(NaN, NaN); | _.eq(NaN, NaN); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_gtvalue-other"></a>`_.gt(value, other)` | <h3 id="_gtvalue-other"><code>_.gt(value, other)</code></h3> | |
<a href="#_gtvalue-other">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11279 "View | |
/4.0.0/lodash.js#L9210 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.gt "See the npm pack | |
mjs.com/package/lodash.gt "See the npm package") | age") [Ⓣ][1] | |
Checks if `value` is greater than `other`. | Checks if `value` is greater than `other`. | |
#### Since | ||
3.9.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is greater than `other`, else `false`. | *(boolean)*: Returns `true` if `value` is greater than `other`, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.gt(3, 1); | _.gt(3, 1); | |
// => true | // => true | |
_.gt(3, 3); | _.gt(3, 3); | |
// => false | // => false | |
_.gt(1, 3); | _.gt(1, 3); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_gtevalue-other"></a>`_.gte(value, other)` | <h3 id="_gtevalue-other"><code>_.gte(value, other)</code></h3> | |
<a href="#_gtevalue-other">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11304 "View | |
b/4.0.0/lodash.js#L9234 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.gte "See the npm pac | |
pmjs.com/package/lodash.gte "See the npm package") | kage") [Ⓣ][1] | |
Checks if `value` is greater than or equal to `other`. | Checks if `value` is greater than or equal to `other`. | |
#### Since | ||
3.9.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is greater than or equal to `other`, els e `false`. | *(boolean)*: Returns `true` if `value` is greater than or equal to `other`, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.gte(3, 1); | _.gte(3, 1); | |
// => true | // => true | |
_.gte(3, 3); | _.gte(3, 3); | |
// => true | // => true | |
_.gte(1, 3); | _.gte(1, 3); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isargumentsvalue"></a>`_.isArguments(value)` | <h3 id="_isargumentsvalue"><code>_.isArguments(value)</code></h3> | |
<a href="#_isargumentsvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11326 "View | |
lob/4.0.0/lodash.js#L9254 "View in source") [Ⓣ][1] [Ⓝ](https://www | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the | |
.npmjs.com/package/lodash.isarguments "See the npm package") | npm package") [Ⓣ][1] | |
Checks if `value` is likely an `arguments` object. | Checks if `value` is likely an `arguments` object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is an `arguments` object, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isArguments(function() { return arguments; }()); | _.isArguments(function() { return arguments; }()); | |
// => true | // => true | |
_.isArguments([1, 2, 3]); | _.isArguments([1, 2, 3]); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isarrayvalue"></a>`_.isArray(value)` | <h3 id="_isarrayvalue"><code>_.isArray(value)</code></h3> | |
<a href="#_isarrayvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11354 "View | |
4.0.0/lodash.js#L9283 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm | |
js.com/package/lodash.isarray "See the npm package") | package") [Ⓣ][1] | |
Checks if `value` is classified as an `Array` object. | Checks if `value` is classified as an `Array` object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is an array, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isArray([1, 2, 3]); | _.isArray([1, 2, 3]); | |
// => true | // => true | |
_.isArray(document.body.children); | _.isArray(document.body.children); | |
// => false | // => false | |
_.isArray('abc'); | _.isArray('abc'); | |
// => false | // => false | |
_.isArray(_.noop); | _.isArray(_.noop); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_isarraybuffervalue"><code>_.isArrayBuffer(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11373 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.isarraybuffer "See t | ||
he npm package") [Ⓣ][1] | ||
Checks if `value` is classified as an `ArrayBuffer` object. | ||
#### Since | ||
4.3.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to check. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `value` is an array buffer, else `false`. | ||
#### Example | ||
```js | ||
_.isArrayBuffer(new ArrayBuffer(2)); | ||
// => true | ||
_.isArrayBuffer(new Array(2)); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isarraylikevalue"></a>`_.isArrayLike(value)` | <h3 id="_isarraylikevalue"><code>_.isArrayLike(value)</code></h3> | |
<a href="#_isarraylikevalue">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11400 "View | |
lob/4.0.0/lodash.js#L9310 "View in source") [Ⓣ][1] [Ⓝ](https://www | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isarraylike "See the | |
.npmjs.com/package/lodash.isarraylike "See the npm package") | npm package") [Ⓣ][1] | |
Checks if `value` is array-like. A value is considered array-like if it's | 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 | 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`. | equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is array-like, else `false`. | *(boolean)*: Returns `true` if `value` is array-like, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isArrayLike([1, 2, 3]); | _.isArrayLike([1, 2, 3]); | |
// => true | // => true | |
_.isArrayLike(document.body.children); | _.isArrayLike(document.body.children); | |
// => true | // => true | |
_.isArrayLike('abc'); | _.isArrayLike('abc'); | |
// => true | // => true | |
_.isArrayLike(_.noop); | _.isArrayLike(_.noop); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isarraylikeobjectvalue"></a>`_.isArrayLikeObject(value)` | <h3 id="_isarraylikeobjectvalue"><code>_.isArrayLikeObject(value)</code></h3> | |
<a href="#_isarraylikeobjectvalue">#</a> [Ⓢ](https://github.com/lodash/lo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11429 "View | |
dash/blob/4.0.0/lodash.js#L9339 "View in source") [Ⓣ][1] [Ⓝ](https | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isarraylikeobject "S | |
://www.npmjs.com/package/lodash.isarraylikeobject "See the npm package") | ee the npm package") [Ⓣ][1] | |
This method is like `_.isArrayLike` except that it also checks if `value` | This method is like `_.isArrayLike` except that it also checks if `value` | |
is an object. | is an object. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is an array-like object, else `false`. | *(boolean)*: Returns `true` if `value` is an array-like object, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isArrayLikeObject([1, 2, 3]); | _.isArrayLikeObject([1, 2, 3]); | |
// => true | // => true | |
_.isArrayLikeObject(document.body.children); | _.isArrayLikeObject(document.body.children); | |
// => true | // => true | |
_.isArrayLikeObject('abc'); | _.isArrayLikeObject('abc'); | |
// => false | // => false | |
_.isArrayLikeObject(_.noop); | _.isArrayLikeObject(_.noop); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isbooleanvalue"></a>`_.isBoolean(value)` | <h3 id="_isbooleanvalue"><code>_.isBoolean(value)</code></h3> | |
<a href="#_isbooleanvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11450 "View | |
b/4.0.0/lodash.js#L9359 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the n | |
pmjs.com/package/lodash.isboolean "See the npm package") | pm package") [Ⓣ][1] | |
Checks if `value` is classified as a boolean primitive or object. | Checks if `value` is classified as a boolean primitive or object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a boolean, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isBoolean(false); | _.isBoolean(false); | |
// => true | // => true | |
_.isBoolean(null); | _.isBoolean(null); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isdatevalue"></a>`_.isDate(value)` | <h3 id="_isbuffervalue"><code>_.isBuffer(value)</code></h3> | |
<a href="#_isdatevalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11472 "View | |
.0.0/lodash.js#L9380 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmj | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isbuffer "See the np | |
s.com/package/lodash.isdate "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is a buffer. | ||
#### Since | ||
4.3.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to check. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `value` is a buffer, else `false`. | ||
#### Example | ||
```js | ||
_.isBuffer(new Buffer(2)); | ||
// => true | ||
_.isBuffer(new Uint8Array(2)); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_isdatevalue"><code>_.isDate(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11491 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm | ||
package") [Ⓣ][1] | ||
Checks if `value` is classified as a `Date` object. | Checks if `value` is classified as a `Date` object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a date object, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isDate(new Date); | _.isDate(new Date); | |
// => true | // => true | |
_.isDate('Mon April 23 2012'); | _.isDate('Mon April 23 2012'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_iselementvalue"></a>`_.isElement(value)` | <h3 id="_iselementvalue"><code>_.isElement(value)</code></h3> | |
<a href="#_iselementvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11510 "View | |
b/4.0.0/lodash.js#L9400 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the n | |
pmjs.com/package/lodash.iselement "See the npm package") | pm package") [Ⓣ][1] | |
Checks if `value` is likely a DOM element. | Checks if `value` is likely a DOM element. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is a DOM element, else `false`. | *(boolean)*: Returns `true` if `value` is a DOM element, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isElement(document.body); | _.isElement(document.body); | |
// => true | // => true | |
_.isElement('<body>'); | _.isElement('<body>'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isemptyvalue"></a>`_.isEmpty(value)` | <h3 id="_isemptyvalue"><code>_.isEmpty(value)</code></h3> | |
<a href="#_isemptyvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11547 "View | |
4.0.0/lodash.js#L9431 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm | |
js.com/package/lodash.isempty "See the npm package") | package") [Ⓣ][1] | |
Checks if `value` is empty. A value is considered empty unless it's an | Checks if `value` is an empty object, collection, map, or set. | |
`arguments` object, array, string, or jQuery-like collection with a length | <br> | |
greater than `0` or an object with own enumerable properties. | <br> | |
Objects are considered empty if they have no own enumerable string keyed | ||
properties. | ||
<br> | ||
<br> | ||
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 | #### Arguments | |
1. `value` *(Array|Object|string)*: The value to inspect. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is empty, else `false`. | *(boolean)*: Returns `true` if `value` is empty, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isEmpty(null); | _.isEmpty(null); | |
// => true | // => true | |
_.isEmpty(true); | _.isEmpty(true); | |
// => true | // => true | |
_.isEmpty(1); | _.isEmpty(1); | |
// => true | // => true | |
_.isEmpty([1, 2, 3]); | _.isEmpty([1, 2, 3]); | |
// => false | // => false | |
_.isEmpty({ 'a': 1 }); | _.isEmpty({ 'a': 1 }); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isequalvalue-other"></a>`_.isEqual(value, other)` | <h3 id="_isequalvalue-other"><code>_.isEqual(value, other)</code></h3> | |
<a href="#_isequalvalue-other">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11599 "View | |
/blob/4.0.0/lodash.js#L9464 "View in source") [Ⓣ][1] [Ⓝ](https://w | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm | |
ww.npmjs.com/package/lodash.isequal "See the npm package") | package") [Ⓣ][1] | |
Performs a deep comparison between two values to determine if they are | Performs a deep comparison between two values to determine if they are | |
equivalent. | equivalent. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method supports comparing arrays, array buffers, booleans, | **Note:** This method supports comparing arrays, array buffers, booleans, | |
date objects, error objects, maps, numbers, `Object` objects, regexes, | date objects, error objects, maps, numbers, `Object` objects, regexes, | |
sets, strings, symbols, and typed arrays. `Object` objects are compared | sets, strings, symbols, and typed arrays. `Object` objects are compared | |
by their own, not inherited, enumerable properties. Functions and DOM | by their own, not inherited, enumerable properties. Functions and DOM | |
nodes are **not** supported. | nodes are compared by strict equality, i.e. `===`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if the values are equivalent, else `false`. | *(boolean)*: Returns `true` if the values are equivalent, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
var object = { 'user': 'fred' }; | var object = { 'a': 1 }; | |
var other = { 'user': 'fred' }; | var other = { 'a': 1 }; | |
_.isEqual(object, other); | _.isEqual(object, other); | |
// => true | // => true | |
object === other; | object === other; | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isequalwithvalue-other-customizer"></a>`_.isEqualWith(value, other, | <h3 id="_isequalwithvalue-other-customizer"><code>_.isEqualWith(value, other, [c | |
[customizer])` | ustomizer])</code></h3> | |
<a href="#_isequalwithvalue-other-customizer">#</a> [Ⓢ](https://github.co | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11635 "View | |
m/lodash/lodash/blob/4.0.0/lodash.js#L9499 "View in source") [Ⓣ][1] [ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isequalwith "See the | |
4C3;](https://www.npmjs.com/package/lodash.isequalwith "See the npm package") | npm package") [Ⓣ][1] | |
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])*. | ||
This method is like `_.isEqual` except that it accepts `customizer` which is | #### Since | |
invoked to compare values. If `customizer` returns `undefined` comparisons are | 4.0.0 | |
handled by the method instead. The `customizer` is invoked with up to seven argu | ||
ments:<br> | ||
(objValue, othValue [, index|key, object, other, stack]). | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
3. `[customizer]` *(Function)*: The function to customize comparisons. | 3. `[customizer]` *(Function)*: The function to customize comparisons. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if the values are equivalent, else `false`. | *(boolean)*: Returns `true` if the values are equivalent, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
function isGreeting(value) { | function isGreeting(value) { | |
return /^h(?:i|ello)$/.test(value); | return /^h(?:i|ello)$/.test(value); | |
} | } | |
function customizer(objValue, othValue) { | function customizer(objValue, othValue) { | |
if (isGreeting(objValue) && isGreeting(othValue)) { | if (isGreeting(objValue) && isGreeting(othValue)) { | |
return true; | return true; | |
} | } | |
} | } | |
var array = ['hello', 'goodbye']; | var array = ['hello', 'goodbye']; | |
var other = ['hi', 'goodbye']; | var other = ['hi', 'goodbye']; | |
_.isEqualWith(array, other, customizer); | _.isEqualWith(array, other, customizer); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_iserrorvalue"></a>`_.isError(value)` | <h3 id="_iserrorvalue"><code>_.isError(value)</code></h3> | |
<a href="#_iserrorvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11659 "View | |
4.0.0/lodash.js#L9522 "View in source") [Ⓣ][1] [Ⓝ](https://www.npm | in source") [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm | |
js.com/package/lodash.iserror "See the npm package") | package") [Ⓣ][1] | |
Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, | Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, | |
`SyntaxError`, `TypeError`, or `URIError` object. | `SyntaxError`, `TypeError`, or `URIError` object. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is an error object, else `false`. | *(boolean)*: Returns `true` if `value` is an error object, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isError(new Error); | _.isError(new Error); | |
// => true | // => true | |
_.isError(Error); | _.isError(Error); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isfinitevalue"></a>`_.isFinite(value)` | <h3 id="_isfinitevalue"><code>_.isFinite(value)</code></h3> | |
<a href="#_isfinitevalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11694 "View | |
/4.0.0/lodash.js#L9551 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the np | |
mjs.com/package/lodash.isfinite "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is a finite primitive number. | Checks if `value` is a finite primitive number. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFi | **Note:** This method is based on | |
nite). | [`Number.isFinite`](https://mdn.io/Number/isFinite). | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is a finite number, else `false`. | *(boolean)*: Returns `true` if `value` is a finite number, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isFinite(3); | _.isFinite(3); | |
// => true | // => true | |
_.isFinite(Number.MAX_VALUE); | _.isFinite(Number.MIN_VALUE); | |
// => true | ||
_.isFinite(3.14); | ||
// => true | // => true | |
_.isFinite(Infinity); | _.isFinite(Infinity); | |
// => false | // => false | |
_.isFinite('3'); | ||
// => false | ||
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isfunctionvalue"></a>`_.isFunction(value)` | <h3 id="_isfunctionvalue"><code>_.isFunction(value)</code></h3> | |
<a href="#_isfunctionvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/bl | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11715 "View | |
ob/4.0.0/lodash.js#L9571 "View in source") [Ⓣ][1] [Ⓝ](https://www. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the | |
npmjs.com/package/lodash.isfunction "See the npm package") | npm package") [Ⓣ][1] | |
Checks if `value` is classified as a `Function` object. | Checks if `value` is classified as a `Function` object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a function, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isFunction(_); | _.isFunction(_); | |
// => true | // => true | |
_.isFunction(/abc/); | _.isFunction(/abc/); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isintegervalue"></a>`_.isInteger(value)` | <h3 id="_isintegervalue"><code>_.isInteger(value)</code></h3> | |
<a href="#_isintegervalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11751 "View | |
b/4.0.0/lodash.js#L9603 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isinteger "See the n | |
pmjs.com/package/lodash.isinteger "See the npm package") | pm package") [Ⓣ][1] | |
Checks if `value` is an integer. | Checks if `value` is an integer. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isI | **Note:** This method is based on | |
nteger). | [`Number.isInteger`](https://mdn.io/Number/isInteger). | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is an integer, else `false`. | *(boolean)*: Returns `true` if `value` is an integer, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isInteger(3); | _.isInteger(3); | |
// => true | // => true | |
_.isInteger(Number.MIN_VALUE); | _.isInteger(Number.MIN_VALUE); | |
// => false | // => false | |
_.isInteger(Infinity); | _.isInteger(Infinity); | |
// => false | // => false | |
_.isInteger('3'); | _.isInteger('3'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_islengthvalue"></a>`_.isLength(value)` | <h3 id="_islengthvalue"><code>_.isLength(value)</code></h3> | |
<a href="#_islengthvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11781 "View | |
/4.0.0/lodash.js#L9631 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.islength "See the np | |
mjs.com/package/lodash.islength "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is a valid array-like length. | Checks if `value` is a valid array-like length. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This function is loosely based on [`ToLength`](http://ecma-internation | **Note:** This method is loosely based on | |
al.org/ecma-262/6.0/#sec-tolength). | [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is a valid length, else `false`. | *(boolean)*: Returns `true` if `value` is a valid length, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isLength(3); | _.isLength(3); | |
// => true | // => true | |
_.isLength(Number.MIN_VALUE); | _.isLength(Number.MIN_VALUE); | |
// => false | // => false | |
_.isLength(Infinity); | _.isLength(Infinity); | |
// => false | // => false | |
_.isLength('3'); | _.isLength('3'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_ismatchobject-source"></a>`_.isMatch(object, source)` | <h3 id="_ismapvalue"><code>_.isMap(value)</code></h3> | |
<a href="#_ismatchobject-source">#</a> [Ⓢ](https://github.com/lodash/loda | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11861 "View | |
sh/blob/4.0.0/lodash.js#L9714 "View in source") [Ⓣ][1] [Ⓝ](https:/ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.ismap "See the npm p | |
/www.npmjs.com/package/lodash.ismatch "See the npm package") | ackage") [Ⓣ][1] | |
Checks if `value` is classified as a `Map` object. | ||
Performs a deep comparison between `object` and `source` to determine if | #### Since | |
`object` contains equivalent property values. | 4.3.0 | |
#### Arguments | ||
1. `value` *(*)*: The value to check. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `value` is a map, else `false`. | ||
#### Example | ||
```js | ||
_.isMap(new Map); | ||
// => true | ||
_.isMap(new WeakMap); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_ismatchobject-source"><code>_.isMatch(object, source)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11891 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm | ||
package") [Ⓣ][1] | ||
Performs a partial deep comparison between `object` and `source` to | ||
determine if `object` contains equivalent property values. | ||
<br> | <br> | |
<br> | <br> | |
**Note:** This method supports comparing the same values as `_.isEqual`. | **Note:** This method is equivalent to `_.matches` when `source` is | |
partially applied. | ||
<br> | ||
<br> | ||
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 | #### Arguments | |
1. `object` *(Object)*: The object to inspect. | 1. `object` *(Object)*: The object to inspect. | |
2. `source` *(Object)*: The object of property values to match. | 2. `source` *(Object)*: The object of property values to match. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `object` is a match, else `false`. | *(boolean)*: Returns `true` if `object` is a match, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
var object = { 'user': 'fred', 'age': 40 }; | var object = { 'a': 1, 'b': 2 }; | |
_.isMatch(object, { 'age': 40 }); | _.isMatch(object, { 'b': 2 }); | |
// => true | // => true | |
_.isMatch(object, { 'age': 36 }); | _.isMatch(object, { 'b': 1 }); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_ismatchwithobject-source-customizer"></a>`_.isMatchWith(object, sour | <h3 id="_ismatchwithobject-source-customizer"><code>_.isMatchWith(object, source | |
ce, [customizer])` | , [customizer])</code></h3> | |
<a href="#_ismatchwithobject-source-customizer">#</a> [Ⓢ](https://github. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11927 "View | |
com/lodash/lodash/blob/4.0.0/lodash.js#L9749 "View in source") [Ⓣ][1] [&# | in source") [Ⓝ](https://www.npmjs.com/package/lodash.ismatchwith "See the | |
x24C3;](https://www.npmjs.com/package/lodash.ismatchwith "See the npm package") | npm package") [Ⓣ][1] | |
This method is like `_.isMatch` except that it accepts `customizer` which | This method is like `_.isMatch` except that it accepts `customizer` which | |
is invoked to compare values. If `customizer` returns `undefined` comparisons | is invoked to compare values. If `customizer` returns `undefined`, comparisons | |
are handled by the method instead. The `customizer` is invoked with three | are handled by the method instead. The `customizer` is invoked with five | |
arguments: (objValue, srcValue, index|key, object, source). | arguments: *(objValue, srcValue, index|key, object, source)*. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `object` *(Object)*: The object to inspect. | 1. `object` *(Object)*: The object to inspect. | |
2. `source` *(Object)*: The object of property values to match. | 2. `source` *(Object)*: The object of property values to match. | |
3. `[customizer]` *(Function)*: The function to customize comparisons. | 3. `[customizer]` *(Function)*: The function to customize comparisons. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `object` is a match, else `false`. | *(boolean)*: Returns `true` if `object` is a match, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
function isGreeting(value) { | function isGreeting(value) { | |
return /^h(?:i|ello)$/.test(value); | return /^h(?:i|ello)$/.test(value); | |
} | } | |
function customizer(objValue, srcValue) { | function customizer(objValue, srcValue) { | |
if (isGreeting(objValue) && isGreeting(srcValue)) { | if (isGreeting(objValue) && isGreeting(srcValue)) { | |
return true; | return true; | |
} | } | |
} | } | |
var object = { 'greeting': 'hello' }; | var object = { 'greeting': 'hello' }; | |
var source = { 'greeting': 'hi' }; | var source = { 'greeting': 'hi' }; | |
_.isMatchWith(object, source, customizer); | _.isMatchWith(object, source, customizer); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isnanvalue"></a>`_.isNaN(value)` | <h3 id="_isnanvalue"><code>_.isNaN(value)</code></h3> | |
<a href="#_isnanvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11960 "View | |
0.0/lodash.js#L9779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm p | |
.com/package/lodash.isnan "See the npm package") | ackage") [Ⓣ][1] | |
Checks if `value` is `NaN`. | Checks if `value` is `NaN`. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1. | **Note:** This method is based on | |
2.4) | [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as | |
which returns `true` for `undefined` and other non-numeric values. | global [`isNaN`](https://mdn.io/isNaN) which returns `true` for | |
`undefined` and other non-number values. | ||
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is `NaN`, else `false`. | *(boolean)*: Returns `true` if `value` is `NaN`, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isNaN(NaN); | _.isNaN(NaN); | |
// => true | // => true | |
_.isNaN(new Number(NaN)); | _.isNaN(new Number(NaN)); | |
// => true | // => true | |
isNaN(undefined); | isNaN(undefined); | |
// => true | // => true | |
_.isNaN(undefined); | _.isNaN(undefined); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isnativevalue"></a>`_.isNative(value)` | <h3 id="_isnativevalue"><code>_.isNative(value)</code></h3> | |
<a href="#_isnativevalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11993 "View | |
/4.0.0/lodash.js#L9801 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the np | |
mjs.com/package/lodash.isnative "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is a pristine native function. | ||
<br> | ||
<br> | ||
**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](https://www.npmjs.com/package/babel-polyfill), | ||
which rely on core-js. | ||
Checks if `value` is a native function. | #### Since | |
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is a native function, else `false`. | *(boolean)*: Returns `true` if `value` is a native function, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isNative(Array.prototype.push); | _.isNative(Array.prototype.push); | |
// => true | // => true | |
_.isNative(_); | _.isNative(_); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isnilvalue"></a>`_.isNil(value)` | <h3 id="_isnilvalue"><code>_.isNil(value)</code></h3> | |
<a href="#_isnilvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12041 "View | |
0.0/lodash.js#L9851 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isnil "See the npm p | |
.com/package/lodash.isnil "See the npm package") | ackage") [Ⓣ][1] | |
Checks if `value` is `null` or `undefined`. | Checks if `value` is `null` or `undefined`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is nullish, else `false`. | *(boolean)*: Returns `true` if `value` is nullish, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isNil(null); | _.isNil(null); | |
// => true | // => true | |
_.isNil(void 0); | _.isNil(void 0); | |
// => true | // => true | |
_.isNil(NaN); | _.isNil(NaN); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isnullvalue"></a>`_.isNull(value)` | <h3 id="_isnullvalue"><code>_.isNull(value)</code></h3> | |
<a href="#_isnullvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12017 "View | |
.0.0/lodash.js#L9828 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmj | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm | |
s.com/package/lodash.isnull "See the npm package") | package") [Ⓣ][1] | |
Checks if `value` is `null`. | Checks if `value` is `null`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is `null`, else `false`. | *(boolean)*: Returns `true` if `value` is `null`, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isNull(null); | _.isNull(null); | |
// => true | // => true | |
_.isNull(void 0); | _.isNull(void 0); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isnumbervalue"></a>`_.isNumber(value)` | <h3 id="_isnumbervalue"><code>_.isNumber(value)</code></h3> | |
<a href="#_isnumbervalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12071 "View | |
/4.0.0/lodash.js#L9880 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the np | |
mjs.com/package/lodash.isnumber "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is classified as a `Number` primitive or object. | Checks if `value` is classified as a `Number` primitive or object. | |
<br> | <br> | |
<br> | <br> | |
**Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified | **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are | |
as numbers, use the `_.isFinite` method. | classified as numbers, use the `_.isFinite` method. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a number, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isNumber(3); | _.isNumber(3); | |
// => true | // => true | |
_.isNumber(Number.MIN_VALUE); | _.isNumber(Number.MIN_VALUE); | |
// => true | // => true | |
_.isNumber(Infinity); | _.isNumber(Infinity); | |
// => true | // => true | |
_.isNumber('3'); | _.isNumber('3'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isobjectvalue"></a>`_.isObject(value)` | <h3 id="_isobjectvalue"><code>_.isObject(value)</code></h3> | |
<a href="#_isobjectvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11811 "View | |
/4.0.0/lodash.js#L9658 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the np | |
mjs.com/package/lodash.isobject "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is the | ||
[language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-l | ||
anguage-types) | ||
of `Object`. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `n | ||
ew String('')`)* | ||
Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | #### Since | |
(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')` | 0.1.0 | |
) | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is an object, else `false`. | *(boolean)*: Returns `true` if `value` is an object, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isObject({}); | _.isObject({}); | |
// => true | // => true | |
_.isObject([1, 2, 3]); | _.isObject([1, 2, 3]); | |
// => true | // => true | |
_.isObject(_.noop); | _.isObject(_.noop); | |
// => true | // => true | |
_.isObject(null); | _.isObject(null); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isobjectlikevalue"></a>`_.isObjectLike(value)` | <h3 id="_isobjectlikevalue"><code>_.isObjectLike(value)</code></h3> | |
<a href="#_isobjectlikevalue">#</a> [Ⓢ](https://github.com/lodash/lodash/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11840 "View | |
blob/4.0.0/lodash.js#L9688 "View in source") [Ⓣ][1] [Ⓝ](https://ww | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isobjectlike "See th | |
w.npmjs.com/package/lodash.isobjectlike "See the npm package") | e npm package") [Ⓣ][1] | |
Checks if `value` is object-like. A value is object-like if it's not `null` | Checks if `value` is object-like. A value is object-like if it's not `null` | |
and has a `typeof` result of "object". | and has a `typeof` result of "object". | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is object-like, else `false`. | *(boolean)*: Returns `true` if `value` is object-like, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isObjectLike({}); | _.isObjectLike({}); | |
// => true | // => true | |
_.isObjectLike([1, 2, 3]); | _.isObjectLike([1, 2, 3]); | |
// => true | // => true | |
_.isObjectLike(_.noop); | _.isObjectLike(_.noop); | |
// => false | // => false | |
_.isObjectLike(null); | _.isObjectLike(null); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isplainobjectvalue"></a>`_.isPlainObject(value)` | <h3 id="_isplainobjectvalue"><code>_.isPlainObject(value)</code></h3> | |
<a href="#_isplainobjectvalue">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12104 "View | |
/blob/4.0.0/lodash.js#L9912 "View in source") [Ⓣ][1] [Ⓝ](https://w | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See t | |
ww.npmjs.com/package/lodash.isplainobject "See the npm package") | he npm package") [Ⓣ][1] | |
Checks if `value` is a plain object, that is, an object created by the | Checks if `value` is a plain object, that is, an object created by the | |
`Object` constructor or one with a `[[Prototype]]` of `null`. | `Object` constructor or one with a `[[Prototype]]` of `null`. | |
#### Since | ||
0.8.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is a plain object, else `false`. | *(boolean)*: Returns `true` if `value` is a plain object, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
function Foo() { | function Foo() { | |
this.a = 1; | this.a = 1; | |
} | } | |
_.isPlainObject(new Foo); | _.isPlainObject(new Foo); | |
// => false | // => false | |
_.isPlainObject([1, 2, 3]); | _.isPlainObject([1, 2, 3]); | |
// => false | // => false | |
_.isPlainObject({ 'x': 0, 'y': 0 }); | _.isPlainObject({ 'x': 0, 'y': 0 }); | |
// => true | // => true | |
_.isPlainObject(Object.create(null)); | _.isPlainObject(Object.create(null)); | |
// => true | // => true | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isregexpvalue"></a>`_.isRegExp(value)` | <h3 id="_isregexpvalue"><code>_.isRegExp(value)</code></h3> | |
<a href="#_isregexpvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12134 "View | |
/4.0.0/lodash.js#L9944 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the np | |
mjs.com/package/lodash.isregexp "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is classified as a `RegExp` object. | Checks if `value` is classified as a `RegExp` object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a regexp, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isRegExp(/abc/); | _.isRegExp(/abc/); | |
// => true | // => true | |
_.isRegExp('/abc/'); | _.isRegExp('/abc/'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_issafeintegervalue"></a>`_.isSafeInteger(value)` | <h3 id="_issafeintegervalue"><code>_.isSafeInteger(value)</code></h3> | |
<a href="#_issafeintegervalue">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12163 "View | |
/blob/4.0.0/lodash.js#L9973 "View in source") [Ⓣ][1] [Ⓝ](https://w | in source") [Ⓝ](https://www.npmjs.com/package/lodash.issafeinteger "See t | |
ww.npmjs.com/package/lodash.issafeinteger "See the npm package") | he npm package") [Ⓣ][1] | |
Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 | 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. | double precision number which isn't the result of a rounded unsafe integer. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is based on [`Number.isSafeInteger`](https://mdn.io/Number | **Note:** This method is based on | |
/isSafeInteger). | [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is a safe integer, else `false`. | *(boolean)*: Returns `true` if `value` is a safe integer, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isSafeInteger(3); | _.isSafeInteger(3); | |
// => true | // => true | |
_.isSafeInteger(Number.MIN_VALUE); | _.isSafeInteger(Number.MIN_VALUE); | |
// => false | // => false | |
_.isSafeInteger(Infinity); | _.isSafeInteger(Infinity); | |
// => false | // => false | |
_.isSafeInteger('3'); | _.isSafeInteger('3'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isstringvalue"></a>`_.isString(value)` | <h3 id="_issetvalue"><code>_.isSet(value)</code></h3> | |
<a href="#_isstringvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12184 "View | |
/4.0.0/lodash.js#L9993 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isset "See the npm p | |
mjs.com/package/lodash.isstring "See the npm package") | ackage") [Ⓣ][1] | |
Checks if `value` is classified as a `Set` object. | ||
#### Since | ||
4.3.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to check. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `value` is a set, else `false`. | ||
#### Example | ||
```js | ||
_.isSet(new Set); | ||
// => true | ||
_.isSet(new WeakSet); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_isstringvalue"><code>_.isString(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12203 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the np | ||
m package") [Ⓣ][1] | ||
Checks if `value` is classified as a `String` primitive or object. | Checks if `value` is classified as a `String` primitive or object. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a string, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isString('abc'); | _.isString('abc'); | |
// => true | // => true | |
_.isString(1); | _.isString(1); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_issymbolvalue"></a>`_.isSymbol(value)` | <h3 id="_issymbolvalue"><code>_.isSymbol(value)</code></h3> | |
<a href="#_issymbolvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12225 "View | |
/4.0.0/lodash.js#L10014 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.issymbol "See the np | |
pmjs.com/package/lodash.issymbol "See the npm package") | m package") [Ⓣ][1] | |
Checks if `value` is classified as a `Symbol` primitive or object. | Checks if `value` is classified as a `Symbol` primitive or object. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a symbol, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isSymbol(Symbol.iterator); | _.isSymbol(Symbol.iterator); | |
// => true | // => true | |
_.isSymbol('abc'); | _.isSymbol('abc'); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_istypedarrayvalue"></a>`_.isTypedArray(value)` | <h3 id="_istypedarrayvalue"><code>_.isTypedArray(value)</code></h3> | |
<a href="#_istypedarrayvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12247 "View | |
blob/4.0.0/lodash.js#L10035 "View in source") [Ⓣ][1] [Ⓝ](https://w | in source") [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See th | |
ww.npmjs.com/package/lodash.istypedarray "See the npm package") | e npm package") [Ⓣ][1] | |
Checks if `value` is classified as a typed array. | Checks if `value` is classified as a typed array. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. | *(boolean)*: Returns `true` if `value` is a typed array, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isTypedArray(new Uint8Array); | _.isTypedArray(new Uint8Array); | |
// => true | // => true | |
_.isTypedArray([]); | _.isTypedArray([]); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_isundefinedvalue"></a>`_.isUndefined(value)` | <h3 id="_isundefinedvalue"><code>_.isUndefined(value)</code></h3> | |
<a href="#_isundefinedvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12266 "View | |
lob/4.0.0/lodash.js#L10055 "View in source") [Ⓣ][1] [Ⓝ](https://ww | in source") [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the | |
w.npmjs.com/package/lodash.isundefined "See the npm package") | npm package") [Ⓣ][1] | |
Checks if `value` is `undefined`. | Checks if `value` is `undefined`. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to check. | 1. `value` *(*)*: The value to check. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is `undefined`, else `false`. | *(boolean)*: Returns `true` if `value` is `undefined`, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.isUndefined(void 0); | _.isUndefined(void 0); | |
// => true | // => true | |
_.isUndefined(null); | _.isUndefined(null); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_isweakmapvalue"><code>_.isWeakMap(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12287 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.isweakmap "See the n | ||
pm package") [Ⓣ][1] | ||
Checks if `value` is classified as a `WeakMap` object. | ||
#### Since | ||
4.3.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to check. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `value` is a weak map, else `false`. | ||
#### Example | ||
```js | ||
_.isWeakMap(new WeakMap); | ||
// => true | ||
_.isWeakMap(new Map); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_isweaksetvalue"><code>_.isWeakSet(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12308 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.isweakset "See the n | ||
pm package") [Ⓣ][1] | ||
Checks if `value` is classified as a `WeakSet` object. | ||
#### Since | ||
4.3.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to check. | ||
#### Returns | ||
*(boolean)*: Returns `true` if `value` is a weak set, else `false`. | ||
#### Example | ||
```js | ||
_.isWeakSet(new WeakSet); | ||
// => true | ||
_.isWeakSet(new Set); | ||
// => false | ||
``` | ||
--- | ||
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_ltvalue-other"></a>`_.lt(value, other)` | <h3 id="_ltvalue-other"><code>_.lt(value, other)</code></h3> | |
<a href="#_ltvalue-other">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12335 "View | |
/4.0.0/lodash.js#L10079 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.lt "See the npm pack | |
pmjs.com/package/lodash.lt "See the npm package") | age") [Ⓣ][1] | |
Checks if `value` is less than `other`. | Checks if `value` is less than `other`. | |
#### Since | ||
3.9.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is less than `other`, else `false`. | *(boolean)*: Returns `true` if `value` is less than `other`, else `false`. | |
#### Example | #### Example | |
```js | ```js | |
_.lt(1, 3); | _.lt(1, 3); | |
// => true | // => true | |
_.lt(3, 3); | _.lt(3, 3); | |
// => false | // => false | |
_.lt(3, 1); | _.lt(3, 1); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_ltevalue-other"></a>`_.lte(value, other)` | <h3 id="_ltevalue-other"><code>_.lte(value, other)</code></h3> | |
<a href="#_ltevalue-other">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12360 "View | |
b/4.0.0/lodash.js#L10103 "View in source") [Ⓣ][1] [Ⓝ](https://www. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.lte "See the npm pac | |
npmjs.com/package/lodash.lte "See the npm package") | kage") [Ⓣ][1] | |
Checks if `value` is less than or equal to `other`. | Checks if `value` is less than or equal to `other`. | |
#### Since | ||
3.9.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to compare. | 1. `value` *(*)*: The value to compare. | |
2. `other` *(*)*: The other value to compare. | 2. `other` *(*)*: The other value to compare. | |
#### Returns | #### Returns | |
*(boolean)*: Returns `true` if `value` is less than or equal to `other`, else ` false`. | *(boolean)*: Returns `true` if `value` is less than or equal to `other`, else `f alse`. | |
#### Example | #### Example | |
```js | ```js | |
_.lte(1, 3); | _.lte(1, 3); | |
// => true | // => true | |
_.lte(3, 3); | _.lte(3, 3); | |
// => true | // => true | |
_.lte(3, 1); | _.lte(3, 1); | |
// => false | // => false | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_toarrayvalue"></a>`_.toArray(value)` | <h3 id="_toarrayvalue"><code>_.toArray(value)</code></h3> | |
<a href="#_toarrayvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/ | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12387 "View | |
4.0.0/lodash.js#L10129 "View in source") [Ⓣ][1] [Ⓝ](https://www.np | in source") [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm | |
mjs.com/package/lodash.toarray "See the npm package") | package") [Ⓣ][1] | |
Converts `value` to an array. | Converts `value` to an array. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to convert. | 1. `value` *(*)*: The value to convert. | |
#### Returns | #### Returns | |
*(Array)*: Returns the converted array. | *(Array)*: Returns the converted array. | |
#### Example | #### Example | |
```js | ```js | |
_.toArray({ 'a': 1, 'b': 2 }); | _.toArray({ 'a': 1, 'b': 2 }); | |
// => [1, 2] | // => [1, 2] | |
_.toArray('abc'); | _.toArray('abc'); | |
// => ['a', 'b', 'c'] | // => ['a', 'b', 'c'] | |
_.toArray(1); | _.toArray(1); | |
// => [] | // => [] | |
_.toArray(null); | _.toArray(null); | |
// => [] | // => [] | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_tointegervalue"></a>`_.toInteger(value)` | <h3 id="_tofinitevalue"><code>_.toFinite(value)</code></h3> | |
<a href="#_tointegervalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blo | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12426 "View | |
b/4.0.0/lodash.js#L10169 "View in source") [Ⓣ][1] [Ⓝ](https://www. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.tofinite "See the np | |
npmjs.com/package/lodash.tointeger "See the npm package") | m package") [Ⓣ][1] | |
Converts `value` to a finite number. | ||
#### Since | ||
4.12.0 | ||
#### Arguments | ||
1. `value` *(*)*: The value to convert. | ||
#### Returns | ||
*(number)*: Returns the converted number. | ||
#### Example | ||
```js | ||
_.toFinite(3.2); | ||
// => 3.2 | ||
_.toFinite(Number.MIN_VALUE); | ||
// => 5e-324 | ||
_.toFinite(Infinity); | ||
// => 1.7976931348623157e+308 | ||
_.toFinite('3.2'); | ||
// => 3.2 | ||
``` | ||
--- | ||
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_tointegervalue"><code>_.toInteger(value)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12464 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.tointeger "See the n | ||
pm package") [Ⓣ][1] | ||
Converts `value` to an integer. | Converts `value` to an integer. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This function is loosely based on [`ToInteger`](http://www.ecma-intern | **Note:** This method is loosely based on | |
ational.org/ecma-262/6.0/#sec-tointeger). | [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to convert. | 1. `value` *(*)*: The value to convert. | |
#### Returns | #### Returns | |
*(number)*: Returns the converted integer. | *(number)*: Returns the converted integer. | |
#### Example | #### Example | |
```js | ```js | |
_.toInteger(3); | _.toInteger(3.2); | |
// => 3 | // => 3 | |
_.toInteger(Number.MIN_VALUE); | _.toInteger(Number.MIN_VALUE); | |
// => 0 | // => 0 | |
_.toInteger(Infinity); | _.toInteger(Infinity); | |
// => 1.7976931348623157e+308 | // => 1.7976931348623157e+308 | |
_.toInteger('3'); | _.toInteger('3.2'); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_tolengthvalue"></a>`_.toLength(value)` | <h3 id="_tolengthvalue"><code>_.toLength(value)</code></h3> | |
<a href="#_tolengthvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12498 "View | |
/4.0.0/lodash.js#L10207 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.tolength "See the np | |
pmjs.com/package/lodash.tolength "See the npm package") | m package") [Ⓣ][1] | |
Converts `value` to an integer suitable for use as the length of an | Converts `value` to an integer suitable for use as the length of an | |
array-like object. | array-like object. | |
<br> | <br> | |
<br> | <br> | |
**Note:** This method is based on [`ToLength`](http://ecma-international.org/ecm | **Note:** This method is based on | |
a-262/6.0/#sec-tolength). | [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to convert. | 1. `value` *(*)*: The value to convert. | |
#### Returns | ||
*(number)*: Returns the converted integer. | ||
#### Example | #### Example | |
```js | ```js | |
_.toLength(3); | _.toLength(3.2); | |
// => 3 | // => 3 | |
_.toLength(Number.MIN_VALUE); | _.toLength(Number.MIN_VALUE); | |
// => 0 | // => 0 | |
_.toLength(Infinity); | _.toLength(Infinity); | |
// => 4294967295 | // => 4294967295 | |
_.toLength('3'); | _.toLength('3.2'); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_tonumbervalue"></a>`_.toNumber(value)` | <h3 id="_tonumbervalue"><code>_.toNumber(value)</code></h3> | |
<a href="#_tonumbervalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12525 "View | |
/4.0.0/lodash.js#L10233 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.tonumber "See the np | |
pmjs.com/package/lodash.tonumber "See the npm package") | m package") [Ⓣ][1] | |
Converts `value` to a number. | Converts `value` to a number. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to process. | 1. `value` *(*)*: The value to process. | |
#### Returns | #### Returns | |
*(number)*: Returns the number. | *(number)*: Returns the number. | |
#### Example | #### Example | |
```js | ```js | |
_.toNumber(3); | _.toNumber(3.2); | |
// => 3 | // => 3.2 | |
_.toNumber(Number.MIN_VALUE); | _.toNumber(Number.MIN_VALUE); | |
// => 5e-324 | // => 5e-324 | |
_.toNumber(Infinity); | _.toNumber(Infinity); | |
// => Infinity | // => Infinity | |
_.toNumber('3'); | _.toNumber('3.2'); | |
// => 3 | // => 3.2 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_toplainobjectvalue"></a>`_.toPlainObject(value)` | <h3 id="_toplainobjectvalue"><code>_.toPlainObject(value)</code></h3> | |
<a href="#_toplainobjectvalue">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12570 "View | |
/blob/4.0.0/lodash.js#L10271 "View in source") [Ⓣ][1] [Ⓝ](https:// | in source") [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See t | |
www.npmjs.com/package/lodash.toplainobject "See the npm package") | he npm package") [Ⓣ][1] | |
Converts `value` to a plain object flattening inherited enumerable | Converts `value` to a plain object flattening inherited enumerable string | |
properties of `value` to own properties of the plain object. | keyed properties of `value` to own properties of the plain object. | |
#### Since | ||
3.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to convert. | 1. `value` *(*)*: The value to convert. | |
#### Returns | #### Returns | |
*(Object)*: Returns the converted plain object. | *(Object)*: Returns the converted plain object. | |
#### Example | #### Example | |
```js | ```js | |
function Foo() { | function Foo() { | |
this.b = 2; | this.b = 2; | |
} | } | |
Foo.prototype.c = 3; | Foo.prototype.c = 3; | |
_.assign({ 'a': 1 }, new Foo); | _.assign({ 'a': 1 }, new Foo); | |
// => { 'a': 1, 'b': 2 } | // => { 'a': 1, 'b': 2 } | |
_.assign({ 'a': 1 }, _.toPlainObject(new Foo)); | _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); | |
// => { 'a': 1, 'b': 2, 'c': 3 } | // => { 'a': 1, 'b': 2, 'c': 3 } | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_tosafeintegervalue"></a>`_.toSafeInteger(value)` | <h3 id="_tosafeintegervalue"><code>_.toSafeInteger(value)</code></h3> | |
<a href="#_tosafeintegervalue">#</a> [Ⓢ](https://github.com/lodash/lodash | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12598 "View | |
/blob/4.0.0/lodash.js#L10298 "View in source") [Ⓣ][1] [Ⓝ](https:// | in source") [Ⓝ](https://www.npmjs.com/package/lodash.tosafeinteger "See t | |
www.npmjs.com/package/lodash.tosafeinteger "See the npm package") | he npm package") [Ⓣ][1] | |
Converts `value` to a safe integer. A safe integer can be compared and | Converts `value` to a safe integer. A safe integer can be compared and | |
represented correctly. | represented correctly. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to convert. | 1. `value` *(*)*: The value to convert. | |
#### Returns | #### Returns | |
*(number)*: Returns the converted integer. | *(number)*: Returns the converted integer. | |
#### Example | #### Example | |
```js | ```js | |
_.toSafeInteger(3); | _.toSafeInteger(3.2); | |
// => 3 | // => 3 | |
_.toSafeInteger(Number.MIN_VALUE); | _.toSafeInteger(Number.MIN_VALUE); | |
// => 0 | // => 0 | |
_.toSafeInteger(Infinity); | _.toSafeInteger(Infinity); | |
// => 9007199254740991 | // => 9007199254740991 | |
_.toSafeInteger('3'); | _.toSafeInteger('3.2'); | |
// => 3 | // => 3 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_tostringvalue"></a>`_.toString(value)` | <h3 id="_tostringvalue"><code>_.toString(value)</code></h3> | |
<a href="#_tostringvalue">#</a> [Ⓢ](https://github.com/lodash/lodash/blob | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L12625 "View | |
/4.0.0/lodash.js#L10322 "View in source") [Ⓣ][1] [Ⓝ](https://www.n | in source") [Ⓝ](https://www.npmjs.com/package/lodash.tostring "See the np | |
pmjs.com/package/lodash.tostring "See the npm package") | m package") [Ⓣ][1] | |
Converts `value` to a string if it's not one. An empty string is returned | Converts `value` to a string. An empty string is returned for `null` | |
for `null` and `undefined` values. The sign of `-0` is preserved. | and `undefined` values. The sign of `-0` is preserved. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `value` *(*)*: The value to process. | 1. `value` *(*)*: The value to convert. | |
#### Returns | #### Returns | |
*(string)*: Returns the string. | *(string)*: Returns the converted string. | |
#### Example | #### Example | |
```js | ```js | |
_.toString(null); | _.toString(null); | |
// => '' | // => '' | |
_.toString(-0); | _.toString(-0); | |
// => '-0' | // => '-0' | |
_.toString([1, 2, 3]); | _.toString([1, 2, 3]); | |
// => '1,2,3' | // => '1,2,3' | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
## `“Math” Methods` | ## `“Math” Methods` | |
<!-- div --> | <!-- div --> | |
### <a id="_addaugend-addend"></a>`_.add(augend, addend)` | <h3 id="_addaugend-addend"><code>_.add(augend, addend)</code></h3> | |
<a href="#_addaugend-addend">#</a> [Ⓢ](https://github.com/lodash/lodash/b | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16289 "View | |
lob/4.0.0/lodash.js#L13547 "View in source") [Ⓣ][1] [Ⓝ](https://ww | in source") [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm pac | |
w.npmjs.com/package/lodash.add "See the npm package") | kage") [Ⓣ][1] | |
Adds two numbers. | Adds two numbers. | |
#### Since | ||
3.4.0 | ||
#### Arguments | #### Arguments | |
1. `augend` *(number)*: The first number in an addition. | 1. `augend` *(number)*: The first number in an addition. | |
2. `addend` *(number)*: The second number in an addition. | 2. `addend` *(number)*: The second number in an addition. | |
#### Returns | #### Returns | |
*(number)*: Returns the total. | *(number)*: Returns the total. | |
#### Example | #### Example | |
```js | ```js | |
_.add(6, 4); | _.add(6, 4); | |
// => 10 | // => 10 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_ceilnumber-precision0"></a>`_.ceil(number, [precision=0])` | <h3 id="_ceilnumber-precision0"><code>_.ceil(number, [precision=0])</code></h3> | |
<a href="#_ceilnumber-precision0">#</a> [Ⓢ](https://github.com/lodash/lod | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16314 "View | |
ash/blob/4.0.0/lodash.js#L13578 "View in source") [Ⓣ][1] [Ⓝ](https | in source") [Ⓝ](https://www.npmjs.com/package/lodash.ceil "See the npm pa | |
://www.npmjs.com/package/lodash.ceil "See the npm package") | ckage") [Ⓣ][1] | |
Computes `number` rounded up to `precision`. | Computes `number` rounded up to `precision`. | |
#### Since | ||
3.10.0 | ||
#### Arguments | #### Arguments | |
1. `number` *(number)*: The number to round up. | 1. `number` *(number)*: The number to round up. | |
2. `[precision=0]` *(number)*: The precision to round up to. | 2. `[precision=0]` *(number)*: The precision to round up to. | |
#### Returns | #### Returns | |
*(number)*: Returns the rounded up number. | *(number)*: Returns the rounded up number. | |
#### Example | #### Example | |
```js | ```js | |
_.ceil(4.006); | _.ceil(4.006); | |
// => 5 | // => 5 | |
_.ceil(6.004, 2); | _.ceil(6.004, 2); | |
// => 6.01 | // => 6.01 | |
_.ceil(6040, -2); | _.ceil(6040, -2); | |
// => 6100 | // => 6100 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_dividedividend-divisor"><code>_.divide(dividend, divisor)</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16331 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.divide "See the npm | ||
package") [Ⓣ][1] | ||
Divide two numbers. | ||
#### Since | ||
4.7.0 | ||
#### Arguments | ||
1. `dividend` *(number)*: The first number in a division. | ||
2. `divisor` *(number)*: The second number in a division. | ||
#### Returns | ||
*(number)*: Returns the quotient. | ||
#### Example | ||
```js | ||
_.divide(6, 4); | ||
// => 1.5 | ||
``` | ||
--- | ||
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_floornumber-precision0"></a>`_.floor(number, [precision=0])` | <h3 id="_floornumber-precision0"><code>_.floor(number, [precision=0])</code></h3 | |
<a href="#_floornumber-precision0">#</a> [Ⓢ](https://github.com/lodash/lo | > | |
dash/blob/4.0.0/lodash.js#L13600 "View in source") [Ⓣ][1] [Ⓝ](http | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16356 "View | |
s://www.npmjs.com/package/lodash.floor "See the npm package") | in source") [Ⓝ](https://www.npmjs.com/package/lodash.floor "See the npm p | |
ackage") [Ⓣ][1] | ||
Computes `number` rounded down to `precision`. | Computes `number` rounded down to `precision`. | |
#### Since | ||
3.10.0 | ||
#### Arguments | #### Arguments | |
1. `number` *(number)*: The number to round down. | 1. `number` *(number)*: The number to round down. | |
2. `[precision=0]` *(number)*: The precision to round down to. | 2. `[precision=0]` *(number)*: The precision to round down to. | |
#### Returns | #### Returns | |
*(number)*: Returns the rounded down number. | *(number)*: Returns the rounded down number. | |
#### Example | #### Example | |
```js | ```js | |
_.floor(4.006); | _.floor(4.006); | |
// => 4 | // => 4 | |
_.floor(0.046, 2); | _.floor(0.046, 2); | |
// => 0.04 | // => 0.04 | |
_.floor(4060, -2); | _.floor(4060, -2); | |
// => 4000 | // => 4000 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_maxarray"></a>`_.max(array)` | <h3 id="_maxarray"><code>_.max(array)</code></h3> | |
<a href="#_maxarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16376 "View | |
0/lodash.js#L13619 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm pac | |
com/package/lodash.max "See the npm package") | kage") [Ⓣ][1] | |
Computes the maximum value of `array`. If `array` is empty or falsey | Computes the maximum value of `array`. If `array` is empty or falsey, | |
`undefined` is returned. | `undefined` is returned. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to iterate over. | 1. `array` *(Array)*: The array to iterate over. | |
#### Returns | #### Returns | |
*(*)*: Returns the maximum value. | *(*)*: Returns the maximum value. | |
#### Example | #### Example | |
```js | ```js | |
_.max([4, 2, 8, 6]); | _.max([4, 2, 8, 6]); | |
// => 8 | // => 8 | |
_.max([]); | _.max([]); | |
// => undefined | // => undefined | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_maxbyarray-iteratee_identity"></a>`_.maxBy(array, [iteratee=_.identi | <h3 id="_maxbyarray-iteratee_identity"><code>_.maxBy(array, [iteratee=_.identity | |
ty])` | ])</code></h3> | |
<a href="#_maxbyarray-iteratee_identity">#</a> [Ⓢ](https://github.com/lod | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16405 "View | |
ash/lodash/blob/4.0.0/lodash.js#L13647 "View in source") [Ⓣ][1] [Ⓝ | in source") [Ⓝ](https://www.npmjs.com/package/lodash.maxby "See the npm p | |
](https://www.npmjs.com/package/lodash.maxby "See the npm package") | ackage") [Ⓣ][1] | |
This method is like `_.max` except that it accepts `iteratee` which is | This method is like `_.max` except that it accepts `iteratee` which is | |
invoked for each element in `array` to generate the criterion by which | invoked for each element in `array` to generate the criterion by which | |
the value is ranked. The iteratee is invoked with one argument: (value). | the value is ranked. The iteratee is invoked with one argument: *(value)*. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to iterate over. | 1. `array` *(Array)*: The array to iterate over. | |
2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. | 2. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | |
#### Returns | #### Returns | |
*(*)*: Returns the maximum value. | *(*)*: Returns the maximum value. | |
#### Example | #### Example | |
```js | ```js | |
var objects = [{ 'n': 1 }, { 'n': 2 }]; | var objects = [{ 'n': 1 }, { 'n': 2 }]; | |
_.maxBy(objects, function(o) { return o.a; }); | _.maxBy(objects, function(o) { return o.n; }); | |
// => { 'n': 2 } | // => { 'n': 2 } | |
// using the `_.property` iteratee shorthand | // The `_.property` iteratee shorthand. | |
_.maxBy(objects, 'n'); | _.maxBy(objects, 'n'); | |
// => { 'n': 2 } | // => { 'n': 2 } | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_meanarray"></a>`_.mean(array)` | <h3 id="_meanarray"><code>_.mean(array)</code></h3> | |
<a href="#_meanarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0 | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16425 "View | |
.0/lodash.js#L13666 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs | in source") [Ⓝ](https://www.npmjs.com/package/lodash.mean "See the npm pa | |
.com/package/lodash.mean "See the npm package") | ckage") [Ⓣ][1] | |
Computes the mean of the values in `array`. | Computes the mean of the values in `array`. | |
#### Since | ||
4.0.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to iterate over. | 1. `array` *(Array)*: The array to iterate over. | |
#### Returns | #### Returns | |
*(number)*: Returns the mean. | *(number)*: Returns the mean. | |
#### Example | #### Example | |
```js | ```js | |
_.mean([4, 2, 8, 6]); | _.mean([4, 2, 8, 6]); | |
// => 5 | // => 5 | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | ||
<!-- div --> | ||
<h3 id="_meanbyarray-iteratee_identity"><code>_.meanBy(array, [iteratee=_.identi | ||
ty])</code></h3> | ||
[Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16452 "View | ||
in source") [Ⓝ](https://www.npmjs.com/package/lodash.meanby "See the npm | ||
package") [Ⓣ][1] | ||
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. | ||
The iteratee is invoked with one argument: *(value)*. | ||
#### Since | ||
4.7.0 | ||
#### Arguments | ||
1. `array` *(Array)*: The array to iterate over. | ||
2. `[iteratee=_.identity]` *(Function)*: The iteratee invoked per element. | ||
#### Returns | ||
*(number)*: Returns the mean. | ||
#### Example | ||
```js | ||
var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; | ||
_.meanBy(objects, function(o) { return o.n; }); | ||
// => 5 | ||
// The `_.property` iteratee shorthand. | ||
_.meanBy(objects, 'n'); | ||
// => 5 | ||
``` | ||
--- | ||
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_minarray"></a>`_.min(array)` | <h3 id="_minarray"><code>_.min(array)</code></h3> | |
<a href="#_minarray">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/4.0. | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16474 "View | |
0/lodash.js#L13687 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs. | in source") [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm pac | |
com/package/lodash.min "See the npm package") | kage") [Ⓣ][1] | |
Computes the minimum value of `array`. If `array` is empty or falsey | Computes the minimum value of `array`. If `array` is empty or falsey, | |
`undefined` is returned. | `undefined` is returned. | |
#### Since | ||
0.1.0 | ||
#### Arguments | #### Arguments | |
1. `array` *(Array)*: The array to iterate over. | 1. `array` *(Array)*: The array to iterate over. | |
#### Returns | #### Returns | |
*(*)*: Returns the minimum value. | *(*)*: Returns the minimum value. | |
#### Example | #### Example | |
```js | ```js | |
_.min([4, 2, 8, 6]); | _.min([4, 2, 8, 6]); | |
// => 2 | // => 2 | |
_.min([]); | _.min([]); | |
// => undefined | // => undefined | |
``` | ``` | |
* * * | --- | |
<!-- /div --> | <!-- /div --> | |
<!-- div --> | <!-- div --> | |
### <a id="_minbyarray-iteratee_identity"></a>`_.minBy(array, [iteratee=_.identi | <h3 id="_minbyarray-iteratee_identity"><code>_.minBy(array, [iteratee=_.identity | |
ty])` | ])</code></h3> | |
<a href="#_minbyarray-iteratee_identity">#</a> [Ⓢ](https://github.com/lod | [Ⓢ](https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L16503 "View | |
ash/lodash/blob/4.0.0/lodash.js#L13715 "View in source") [Ⓣ][1] [Ⓝ | in source") [& |