# Lo-Dash v2.2.1
## `Arrays`
* [`_.compact`](#_compactarray)
* [`_.difference`](#_differencearray--array)
* [`_.drop`](#_restarray--callback1--thisarg)
* [`_.findIndex`](#_findindexarray--callbackidentity--thisarg)
* [`_.findLastIndex`](#_findlastindexarray--callbackidentity--thisarg)
* [`_.first`](#_firstarray--callback--thisarg)
* [`_.flatten`](#_flattenarray--isshallowfalse--callbackidentity--thisarg)
* [`_.head`](#_firstarray--callback--thisarg)
* [`_.indexOf`](#_indexofarray-value--fromindex0)
* [`_.initial`](#_initialarray--callback1--thisarg)
* [`_.intersection`](#_intersectionarray)
* [`_.last`](#_lastarray--callback--thisarg)
* [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1)
* [`_.object`](#_zipobjectkeys--values)
* [`_.pull`](#_pullarray--value)
* [`_.range`](#_rangestart0-end--step1)
* [`_.remove`](#_removearray--callbackidentity--thisarg)
* [`_.rest`](#_restarray--callback1--thisarg)
* [`_.sortedIndex`](#_sortedindexarray-value--callbackidentity--thisarg)
* [`_.tail`](#_restarray--callback1--thisarg)
* [`_.take`](#_firstarray--callback--thisarg)
* [`_.union`](#_unionarray)
* [`_.uniq`](#_uniqarray--issortedfalse--callbackidentity--thisarg)
* [`_.unique`](#_uniqarray--issortedfalse--callbackidentity--thisarg)
* [`_.unzip`](#_ziparray)
* [`_.without`](#_withoutarray--value)
* [`_.zip`](#_ziparray)
* [`_.zipObject`](#_zipobjectkeys--values)
## `Chaining`
* [`_`](#_value)
* [`_.chain`](#_chainvalue)
* [`_.tap`](#_tapvalue-interceptor)
* [`_.prototype.chain`](#_prototypechain)
* [`_.prototype.toString`](#_prototypetostring)
* [`_.prototype.value`](#_prototypevalueof)
* [`_.prototype.valueOf`](#_prototypevalueof)
## `Collections`
* [`_.all`](#_everycollection--callbackidentity--thisarg)
* [`_.any`](#_somecollection--callbackidentity--thisarg)
* [`_.at`](#_atcollection--index)
* [`_.collect`](#_mapcollection--callbackidentity--thisarg)
* [`_.contains`](#_containscollection-target--fromindex0)
* [`_.countBy`](#_countbycollection--callbackidentity--thisarg)
* [`_.detect`](#_findcollection--callbackidentity--thisarg)
* [`_.each`](#_foreachcollection--callbackidentity--thisarg)
* [`_.eachRight`](#_foreachrightcollection--callbackidentity--thisarg)
* [`_.every`](#_everycollection--callbackidentity--thisarg)
* [`_.filter`](#_filtercollection--callbackidentity--thisarg)
* [`_.find`](#_findcollection--callbackidentity--thisarg)
* [`_.findLast`](#_findlastcollection--callbackidentity--thisarg)
* [`_.findWhere`](#_findcollection--callbackidentity--thisarg)
* [`_.foldl`](#_reducecollection--callbackidentity--accumulator--thisarg)
* [`_.foldr`](#_reducerightcollection--callbackidentity--accumulator--thisarg)
* [`_.forEach`](#_foreachcollection--callbackidentity--thisarg)
* [`_.forEachRight`](#_foreachrightcollection--callbackidentity--thisarg)
* [`_.groupBy`](#_groupbycollection--callbackidentity--thisarg)
* [`_.include`](#_containscollection-target--fromindex0)
* [`_.indexBy`](#_indexbycollection--callbackidentity--thisarg)
* [`_.inject`](#_reducecollection--callbackidentity--accumulator--thisarg)
* [`_.invoke`](#_invokecollection-methodname--arg)
* [`_.map`](#_mapcollection--callbackidentity--thisarg)
* [`_.max`](#_maxcollection--callbackidentity--thisarg)
* [`_.min`](#_mincollection--callbackidentity--thisarg)
* [`_.pluck`](#_pluckcollection-property)
* [`_.reduce`](#_reducecollection--callbackidentity--accumulator--thisarg)
* [`_.reduceRight`](#_reducerightcollection--callbackidentity--accumulator--thisarg)
* [`_.reject`](#_rejectcollection--callbackidentity--thisarg)
* [`_.sample`](#_samplecollection--n)
* [`_.select`](#_filtercollection--callbackidentity--thisarg)
* [`_.shuffle`](#_shufflecollection)
* [`_.size`](#_sizecollection)
* [`_.some`](#_somecollection--callbackidentity--thisarg)
* [`_.sortBy`](#_sortbycollection--callbackidentity--thisarg)
* [`_.toArray`](#_toarraycollection)
* [`_.where`](#_wherecollection-properties)
## `Functions`
* [`_.after`](#_aftern-func)
* [`_.bind`](#_bindfunc--thisarg--arg)
* [`_.bindAll`](#_bindallobject--methodname)
* [`_.bindKey`](#_bindkeyobject-key--arg)
* [`_.compose`](#_composefunc)
* [`_.createCallback`](#_createcallbackfuncidentity--thisarg--argcount)
* [`_.curry`](#_curryfunc--arityfunclength)
* [`_.debounce`](#_debouncefunc-wait--options--optionsmaxwait)
* [`_.defer`](#_deferfunc--arg)
* [`_.delay`](#_delayfunc-wait--arg)
* [`_.memoize`](#_memoizefunc--resolver)
* [`_.once`](#_oncefunc)
* [`_.partial`](#_partialfunc--arg)
* [`_.partialRight`](#_partialrightfunc--arg)
* [`_.throttle`](#_throttlefunc-wait--options)
* [`_.wrap`](#_wrapvalue-wrapper)
## `Objects`
* [`_.assign`](#_assignobject--source--callback--thisarg)
* [`_.clone`](#_clonevalue--deepfalse--callback--thisarg)
* [`_.cloneDeep`](#_clonedeepvalue--callback--thisarg)
* [`_.create`](#_createprototype--properties)
* [`_.defaults`](#_defaultsobject--source)
* [`_.extend`](#_assignobject--source--callback--thisarg)
* [`_.findKey`](#_findkeyobject--callbackidentity--thisarg)
* [`_.findLastKey`](#_findlastkeyobject--callbackidentity--thisarg)
* [`_.forIn`](#_forinobject--callbackidentity--thisarg)
* [`_.forInRight`](#_forinrightobject--callbackidentity--thisarg)
* [`_.forOwn`](#_forownobject--callbackidentity--thisarg)
* [`_.forOwnRight`](#_forownrightobject--callbackidentity--thisarg)
* [`_.functions`](#_functionsobject)
* [`_.has`](#_hasobject-property)
* [`_.invert`](#_invertobject)
* [`_.isArguments`](#_isargumentsvalue)
* [`_.isArray`](#_isarrayvalue)
* [`_.isBoolean`](#_isbooleanvalue)
* [`_.isDate`](#_isdatevalue)
* [`_.isElement`](#_iselementvalue)
* [`_.isEmpty`](#_isemptyvalue)
* [`_.isEqual`](#_isequala-b--callback--thisarg)
* [`_.isFinite`](#_isfinitevalue)
* [`_.isFunction`](#_isfunctionvalue)
* [`_.isNaN`](#_isnanvalue)
* [`_.isNull`](#_isnullvalue)
* [`_.isNumber`](#_isnumbervalue)
* [`_.isObject`](#_isobjectvalue)
* [`_.isPlainObject`](#_isplainobjectvalue)
* [`_.isRegExp`](#_isregexpvalue)
* [`_.isString`](#_isstringvalue)
* [`_.isUndefined`](#_isundefinedvalue)
* [`_.keys`](#_keysobject)
* [`_.merge`](#_mergeobject--source--callback--thisarg)
* [`_.methods`](#_functionsobject)
* [`_.omit`](#_omitobject--callback--thisarg)
* [`_.pairs`](#_pairsobject)
* [`_.pick`](#_pickobject--callback--thisarg)
* [`_.transform`](#_transformobject--callbackidentity--accumulator--thisarg)
* [`_.values`](#_valuesobject)
## `Utilities`
* [`_.escape`](#_escapestring)
* [`_.identity`](#_identityvalue)
* [`_.mixin`](#_mixinobject-object)
* [`_.noConflict`](#_noconflict)
* [`_.parseInt`](#_parseintvalue--radix)
* [`_.random`](#_randommin0--max1--floatingfalse)
* [`_.result`](#_resultobject-property)
* [`_.runInContext`](#_runincontextcontextroot)
* [`_.template`](#_templatetext-data--options--optionsescape--optionsevaluate--optionsimports--optionsinterpolate--sourceurl--variable)
* [`_.times`](#_timesn-callback--thisarg)
* [`_.unescape`](#_unescapestring)
* [`_.uniqueId`](#_uniqueidprefix)
## `Methods`
* [`_.templateSettings.imports._`](#_templatesettingsimports_)
## `Properties`
* [`_.VERSION`](#_version)
* [`_.support`](#_support)
* [`_.support.argsClass`](#_supportargsclass)
* [`_.support.argsObject`](#_supportargsobject)
* [`_.support.enumErrorProps`](#_supportenumerrorprops)
* [`_.support.enumPrototypes`](#_supportenumprototypes)
* [`_.support.fastBind`](#_supportfastbind)
* [`_.support.funcDecomp`](#_supportfuncdecomp)
* [`_.support.funcNames`](#_supportfuncnames)
* [`_.support.nonEnumArgs`](#_supportnonenumargs)
* [`_.support.nonEnumShadows`](#_supportnonenumshadows)
* [`_.support.ownLast`](#_supportownlast)
* [`_.support.spliceObjects`](#_supportspliceobjects)
* [`_.support.unindexedChars`](#_supportunindexedchars)
* [`_.templateSettings`](#_templatesettings)
* [`_.templateSettings.escape`](#_templatesettingsescape)
* [`_.templateSettings.evaluate`](#_templatesettingsevaluate)
* [`_.templateSettings.interpolate`](#_templatesettingsinterpolate)
* [`_.templateSettings.variable`](#_templatesettingsvariable)
* [`_.templateSettings.imports`](#_templatesettingsimports)
## `“Arrays” Methods`
### `_.compact(array)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4298 "View in source") [Ⓣ][1]
Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are all falsey.
#### Arguments
1. `array` *(Array)*: The array to compact.
#### Returns
*(Array)*: Returns a new array of filtered values.
#### Example
```js
_.compact([0, 1, false, 2, '', 3]);
// => [1, 2, 3]
```
* * *
### `_.difference(array, [array])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4327 "View in source") [Ⓣ][1]
Creates an array excluding all values of the provided arrays using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `array` *(Array)*: The array to process.
2. `[array]` *(...Array)*: The arrays of values to exclude.
#### Returns
*(Array)*: Returns a new array of filtered values.
#### Example
```js
_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
// => [1, 3, 4]
```
* * *
### `_.findIndex(array, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4398 "View in source") [Ⓣ][1]
This method is like `_.find` except that it returns the index of the first element that passes the callback check, instead of the element itself.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to search.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(number)*: Returns the index of the found element, else `-1`.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36, 'blocked': false },
{ 'name': 'fred', 'age': 40, 'blocked': true },
{ 'name': 'pebbles', 'age': 1, 'blocked': false }
];
_.findIndex(characters, function(chr) {
return chr.age < 20;
});
// => 2
// using "_.where" callback shorthand
_.findIndex(characters, { 'age': 36 });
// => 0
// using "_.pluck" callback shorthand
_.findIndex(characters, 'blocked');
// => 1
```
* * *
### `_.findLastIndex(array, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4452 "View in source") [Ⓣ][1]
This method is like `_.findIndex` except that it iterates over elements of a `collection` from right to left.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to search.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(number)*: Returns the index of the found element, else `-1`.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36, 'blocked': true },
{ 'name': 'fred', 'age': 40, 'blocked': false },
{ 'name': 'pebbles', 'age': 1, 'blocked': true }
];
_.findLastIndex(characters, function(chr) {
return chr.age > 30;
});
// => 1
// using "_.where" callback shorthand
_.findLastIndex(characters, { 'age': 36 });
// => 0
// using "_.pluck" callback shorthand
_.findLastIndex(characters, 'blocked');
// => 2
```
* * *
### `_.first(array, [callback], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4514 "View in source") [Ⓣ][1]
Gets the first element or first `n` elements of an array. If a callback is provided elements at the beginning of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.head, _.take*
#### Arguments
1. `array` *(Array)*: The array to query.
2. `[callback]` *(Function|Object|number|string)*: The function called per element or the number of elements to return. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the first element(s) of `array`.
#### Example
```js
_.first([1, 2, 3]);
// => 1
_.first([1, 2, 3], 2);
// => [1, 2]
_.first([1, 2, 3], function(num) {
return num < 3;
});
// => [1, 2]
var characters = [
{ 'name': 'barney', 'blocked': true, 'employer': 'slate' },
{ 'name': 'fred', 'blocked': false, 'employer': 'slate' },
{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
];
// using "_.pluck" callback shorthand
_.first(characters, 'blocked');
// => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }]
// using "_.where" callback shorthand
_.pluck(_.first(characters, { 'employer': 'slate' }), 'name');
// => ['barney', 'fred']
```
* * *
### `_.flatten(array, [isShallow=false], [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4574 "View in source") [Ⓣ][1]
Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truey, the array will only be flattened a single level. If a callback is provided each element of the array is passed through the callback before flattening. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to flatten.
2. `[isShallow=false]` *(boolean)*: A flag to restrict flattening to a single level.
3. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
4. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a new flattened array.
#### Example
```js
_.flatten([1, [2], [3, [[4]]]]);
// => [1, 2, 3, 4];
_.flatten([1, [2], [3, [[4]]]], true);
// => [1, 2, 3, [[4]]];
var characters = [
{ 'name': 'barney', 'age': 30, 'pets': ['hoppy'] },
{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
];
// using "_.pluck" callback shorthand
_.flatten(characters, 'pets');
// => ['hoppy', 'baby puss', 'dino']
```
* * *
### `_.indexOf(array, value, [fromIndex=0])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4611 "View in source") [Ⓣ][1]
Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the array is already sorted providing `true` for `fromIndex` will run a faster binary search.
#### Arguments
1. `array` *(Array)*: The array to search.
2. `value` *(\*)*: The value to search for.
3. `[fromIndex=0]` *(boolean|number)*: The index to search from or `true` to perform a binary search on a sorted array.
#### Returns
*(number)*: Returns the index of the matched value or `-1`.
#### Example
```js
_.indexOf([1, 2, 3, 1, 2, 3], 2);
// => 1
_.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
// => 4
_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
// => 2
```
* * *
### `_.initial(array, [callback=1], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4672 "View in source") [Ⓣ][1]
Gets all but the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to query.
2. `[callback=1]` *(Function|Object|number|string)*: The function called per element or the number of elements to exclude. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a slice of `array`.
#### Example
```js
_.initial([1, 2, 3]);
// => [1, 2]
_.initial([1, 2, 3], 2);
// => [1]
_.initial([1, 2, 3], function(num) {
return num > 1;
});
// => [1]
var characters = [
{ 'name': 'barney', 'blocked': false, 'employer': 'slate' },
{ 'name': 'fred', 'blocked': true, 'employer': 'slate' },
{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
];
// using "_.pluck" callback shorthand
_.initial(characters, 'blocked');
// => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }]
// using "_.where" callback shorthand
_.pluck(_.initial(characters, { 'employer': 'na' }), 'name');
// => ['barney', 'fred']
```
* * *
### `_.intersection([array])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4702 "View in source") [Ⓣ][1]
Creates an array of unique values present in all provided arrays using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `[array]` *(...Array)*: The arrays to inspect.
#### Returns
*(Array)*: Returns an array of composite values.
#### Example
```js
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// => [1, 2]
```
* * *
### `_.last(array, [callback], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4797 "View in source") [Ⓣ][1]
Gets the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to query.
2. `[callback]` *(Function|Object|number|string)*: The function called per element or the number of elements to return. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the last element(s) of `array`.
#### Example
```js
_.last([1, 2, 3]);
// => 3
_.last([1, 2, 3], 2);
// => [2, 3]
_.last([1, 2, 3], function(num) {
return num > 1;
});
// => [2, 3]
var characters = [
{ 'name': 'barney', 'blocked': false, 'employer': 'slate' },
{ 'name': 'fred', 'blocked': true, 'employer': 'slate' },
{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
];
// using "_.pluck" callback shorthand
_.pluck(_.last(characters, 'blocked'), 'name');
// => ['fred', 'pebbles']
// using "_.where" callback shorthand
_.last(characters, { 'employer': 'na' });
// => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
```
* * *
### `_.lastIndexOf(array, value, [fromIndex=array.length-1])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4843 "View in source") [Ⓣ][1]
Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to search.
2. `value` *(\*)*: The value to search for.
3. `[fromIndex=array.length-1]` *(number)*: The index to search from.
#### Returns
*(number)*: Returns the index of the matched value or `-1`.
#### Example
```js
_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
// => 4
_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
// => 1
```
* * *
### `_.pull(array, [value])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4873 "View in source") [Ⓣ][1]
Removes all provided values from the given array using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `array` *(Array)*: The array to modify.
2. `[value]` *(...\*)*: The values to remove.
#### Returns
*(Array)*: Returns `array`.
#### Example
```js
var array = [1, 2, 3, 1, 2, 3];
_.pull(array, 2, 3);
console.log(array);
// => [1, 1]
```
* * *
### `_.range([start=0], end, [step=1])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4924 "View in source") [Ⓣ][1]
Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. If `start` is less than `stop` a zero-length range is created unless a negative `step` is specified.
#### Arguments
1. `[start=0]` *(number)*: The start of the range.
2. `end` *(number)*: The end of the range.
3. `[step=1]` *(number)*: The value to increment or decrement by.
#### Returns
*(Array)*: Returns a new range array.
#### Example
```js
_.range(4);
// => [0, 1, 2, 3]
_.range(1, 5);
// => [1, 2, 3, 4]
_.range(0, 20, 5);
// => [0, 5, 10, 15]
_.range(0, -4, -1);
// => [0, -1, -2, -3]
_.range(1, 4, 0);
// => [1, 1, 1]
_.range(0);
// => []
```
* * *
### `_.remove(array, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4977 "View in source") [Ⓣ][1]
Removes all elements from an array that the callback returns truey for and returns an array of removed elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to modify.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a new array of removed elements.
#### Example
```js
var array = [1, 2, 3, 4, 5, 6];
var evens = _.remove(array, function(num) { return num % 2 == 0; });
console.log(array);
// => [1, 3, 5]
console.log(evens);
// => [2, 4, 6]
```
* * *
### `_.rest(array, [callback=1], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5046 "View in source") [Ⓣ][1]
The opposite of `_.initial` this method gets all but the first element or first `n` elements of an array. If a callback function is provided elements at the beginning of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.drop, _.tail*
#### Arguments
1. `array` *(Array)*: The array to query.
2. `[callback=1]` *(Function|Object|number|string)*: The function called per element or the number of elements to exclude. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a slice of `array`.
#### Example
```js
_.rest([1, 2, 3]);
// => [2, 3]
_.rest([1, 2, 3], 2);
// => [3]
_.rest([1, 2, 3], function(num) {
return num < 3;
});
// => [3]
var characters = [
{ 'name': 'barney', 'blocked': true, 'employer': 'slate' },
{ 'name': 'fred', 'blocked': false, 'employer': 'slate' },
{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
];
// using "_.pluck" callback shorthand
_.pluck(_.rest(characters, 'blocked'), 'name');
// => ['fred', 'pebbles']
// using "_.where" callback shorthand
_.rest(characters, { 'employer': 'slate' });
// => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
```
* * *
### `_.sortedIndex(array, value, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5110 "View in source") [Ⓣ][1]
Uses a binary search to determine the smallest index at which a value should be inserted into a given sorted array in order to maintain the sort order of the array. If a callback is provided it will be executed for `value` and each element of `array` to compute their sort ranking. The callback is bound to `thisArg` and invoked with one argument; *(value)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `array` *(Array)*: The array to inspect.
2. `value` *(\*)*: The value to evaluate.
3. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
4. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(number)*: Returns the index at which `value` should be inserted into `array`.
#### Example
```js
_.sortedIndex([20, 30, 50], 40);
// => 2
// using "_.pluck" callback shorthand
_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
// => 2
var dict = {
'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
};
_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
return dict.wordToNumber[word];
});
// => 2
_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
return this.wordToNumber[word];
}, dict);
// => 2
```
* * *
### `_.union([array])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5141 "View in source") [Ⓣ][1]
Creates an array of unique values, in order, of the provided arrays using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `[array]` *(...Array)*: The arrays to inspect.
#### Returns
*(Array)*: Returns an array of composite values.
#### Example
```js
_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// => [1, 2, 3, 101, 10]
```
* * *
### `_.uniq(array, [isSorted=false], [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5189 "View in source") [Ⓣ][1]
Creates a duplicate-value-free version of an array using strict equality for comparisons, i.e. `===`. If the array is sorted, providing `true` for `isSorted` will use a faster algorithm. If a callback is provided each element of `array` is passed through the callback before uniqueness is computed. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.unique*
#### Arguments
1. `array` *(Array)*: The array to process.
2. `[isSorted=false]` *(boolean)*: A flag to indicate that `array` is sorted.
3. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
4. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a duplicate-value-free array.
#### Example
```js
_.uniq([1, 2, 1, 3, 1]);
// => [1, 2, 3]
_.uniq([1, 1, 2, 2, 3], true);
// => [1, 2, 3]
_.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); });
// => ['A', 'b', 'C']
_.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math);
// => [1, 2.5, 3]
// using "_.pluck" callback shorthand
_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]
```
* * *
### `_.without(array, [value])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5217 "View in source") [Ⓣ][1]
Creates an array excluding all provided values using strict equality for comparisons, i.e. `===`.
#### Arguments
1. `array` *(Array)*: The array to filter.
2. `[value]` *(...\*)*: The values to exclude.
#### Returns
*(Array)*: Returns a new array of filtered values.
#### Example
```js
_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
// => [2, 3, 4]
```
* * *
### `_.zip([array])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5237 "View in source") [Ⓣ][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.
#### Aliases
*_.unzip*
#### Arguments
1. `[array]` *(...Array)*: Arrays to process.
#### Returns
*(Array)*: Returns a new array of grouped elements.
#### Example
```js
_.zip(['fred', 'barney'], [30, 40], [true, false]);
// => [['fred', 30, true], ['barney', 40, false]]
```
* * *
### `_.zipObject(keys, [values=[]])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5267 "View in source") [Ⓣ][1]
Creates an object composed from arrays of `keys` and `values`. Provide either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` or two arrays, one of `keys` and one of corresponding `values`.
#### Aliases
*_.object*
#### Arguments
1. `keys` *(Array)*: The array of keys.
2. `[values=[]]` *(Array)*: The array of values.
#### Returns
*(Object)*: Returns an object composed of the given keys and corresponding values.
#### Example
```js
_.zipObject(['fred', 'barney'], [30, 40]);
// => { 'fred': 30, 'barney': 40 }
```
* * *
## `“Chaining” Methods`
### `_(value)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L653 "View in source") [Ⓣ][1]
Creates a `lodash` object which wraps the given value to enable intuitive method chaining.
In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
`concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, and `unshift`
Chaining is supported in custom builds as long as the `value` method is implicitly or explicitly included in the build.
The chainable wrapper functions are:
`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`, `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, and `zip`
The non-chainable wrapper functions are:
`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value`
The wrapper functions `first` and `last` return wrapped values when `n` is provided, otherwise they return unwrapped values.
Explicit chaining can be enabled by using the `_.chain` method.
#### Arguments
1. `value` *(\*)*: The value to wrap in a `lodash` instance.
#### Returns
*(Object)*: Returns a `lodash` instance.
#### Example
```js
var wrapped = _([1, 2, 3]);
// returns an unwrapped value
wrapped.reduce(function(sum, num) {
return sum + num;
});
// => 6
// returns a wrapped value
var squares = wrapped.map(function(num) {
return num * num;
});
_.isArray(squares);
// => false
_.isArray(squares.value());
// => true
```
* * *
### `_.chain(value)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6482 "View in source") [Ⓣ][1]
Creates a `lodash` object that wraps the given value with explicit method chaining enabled.
#### Arguments
1. `value` *(\*)*: The value to wrap.
#### Returns
*(Object)*: Returns the wrapper object.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 },
{ 'name': 'pebbles', 'age': 1 }
];
var youngest = _.chain(characters)
.sortBy('age')
.map(function(stooge) { return stooge.name + ' is ' + stooge.age; })
.first()
.value();
// => 'pebbles is 1'
```
* * *
### `_.tap(value, interceptor)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6510 "View in source") [Ⓣ][1]
Invokes `interceptor` with the `value` as the first argument and then returns `value`. The purpose of this method is to "tap into" a method chain in order to perform operations on intermediate results within the chain.
#### Arguments
1. `value` *(\*)*: The value to provide to `interceptor`.
2. `interceptor` *(Function)*: The function to invoke.
#### Returns
*(\*)*: Returns `value`.
#### Example
```js
_([1, 2, 3, 4])
.filter(function(num) { return num % 2 == 0; })
.tap(function(array) { console.log(array); })
.map(function(num) { return num * num; })
.value();
// => // [2, 4] (logged)
// => [4, 16]
```
* * *
### `_.prototype.chain()`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6540 "View in source") [Ⓣ][1]
Enables explicit method chaining on the wrapper object.
#### Returns
*(\*)*: Returns the wrapper object.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
// without explicit chaining
_(characters).first();
// => { 'name': 'barney', 'age': 36 }
// with explicit chaining
_(characters).chain()
.first()
.pick('age')
.value()
// => { 'age': 36 }
```
* * *
### `_.prototype.toString()`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6557 "View in source") [Ⓣ][1]
Produces the `toString` result of the wrapped value.
#### Returns
*(string)*: Returns the string result.
#### Example
```js
_([1, 2, 3]).toString();
// => '1,2,3'
```
* * *
### `_.prototype.valueOf()`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6574 "View in source") [Ⓣ][1]
Extracts the wrapped value.
#### Aliases
*_.prototype.value*
#### Returns
*(\*)*: Returns the wrapped value.
#### Example
```js
_([1, 2, 3]).valueOf();
// => [1, 2, 3]
```
* * *
## `“Collections” Methods`
### `_.at(collection, [index])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3149 "View in source") [Ⓣ][1]
Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[index]` *(...(number|number[]|string|string[])*: The indexes of `collection` to retrieve, specified as individual indexes or arrays of indexes.
#### Returns
*(Array)*: Returns a new array of elements corresponding to the provided indexes.
#### Example
```js
_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
// => ['a', 'c', 'e']
_.at(['fred', 'barney', 'pebbles'], 0, 2);
// => ['fred', 'pebbles']
```
* * *
### `_.contains(collection, target, [fromIndex=0])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3192 "View in source") [Ⓣ][1]
Checks if a given value is present in a collection using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection.
#### Aliases
*_.include*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `target` *(\*)*: The value to check for.
3. `[fromIndex=0]` *(number)*: The index to search from.
#### Returns
*(boolean)*: Returns `true` if the `target` element is found, else `false`.
#### Example
```js
_.contains([1, 2, 3], 1);
// => true
_.contains([1, 2, 3], 1, 2);
// => false
_.contains({ 'name': 'fred', 'age': 40 }, 'fred');
// => true
_.contains('pebbles', 'ur');
// => true
```
* * *
### `_.countBy(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3247 "View in source") [Ⓣ][1]
Creates an object composed of keys generated from the results of running each element of `collection` through the callback. The corresponding value of each key is the number of times the key was returned by the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Object)*: Returns the composed aggregate object.
#### Example
```js
_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
// => { '4': 1, '6': 2 }
_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
// => { '4': 1, '6': 2 }
_.countBy(['one', 'two', 'three'], 'length');
// => { '3': 2, '5': 1 }
```
* * *
### `_.every(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3292 "View in source") [Ⓣ][1]
Checks if the given callback returns truey value for **all** elements of a collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.all*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(boolean)*: Returns `true` if all elements passed the callback check, else `false`.
#### Example
```js
_.every([true, 1, null, 'yes']);
// => false
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
// using "_.pluck" callback shorthand
_.every(characters, 'age');
// => true
// using "_.where" callback shorthand
_.every(characters, { 'age': 36 });
// => false
```
* * *
### `_.filter(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3353 "View in source") [Ⓣ][1]
Iterates over elements of a collection, returning an array of all elements the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.select*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a new array of elements that passed the callback check.
#### Example
```js
var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
// => [2, 4, 6]
var characters = [
{ 'name': 'barney', 'age': 36, 'blocked': false },
{ 'name': 'fred', 'age': 40, 'blocked': true }
];
// using "_.pluck" callback shorthand
_.filter(characters, 'blocked');
// => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
// using "_.where" callback shorthand
_.filter(characters, { 'age': 36 });
// => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
```
* * *
### `_.find(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3420 "View in source") [Ⓣ][1]
Iterates over elements of a collection, returning the first element that the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.detect, _.findWhere*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the found element, else `undefined`.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36, 'blocked': false },
{ 'name': 'fred', 'age': 40, 'blocked': true },
{ 'name': 'pebbles', 'age': 1, 'blocked': false }
];
_.find(characters, function(chr) {
return chr.age < 40;
});
// => { 'name': 'barney', 'age': 36, 'blocked': false }
// using "_.where" callback shorthand
_.find(characters, { 'age': 1 });
// => { 'name': 'pebbles', 'age': 1, 'blocked': false }
// using "_.pluck" callback shorthand
_.find(characters, 'blocked');
// => { 'name': 'fred', 'age': 40, 'blocked': true }
```
* * *
### `_.findLast(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3465 "View in source") [Ⓣ][1]
This method is like `_.find` except that it iterates over elements of a `collection` from right to left.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the found element, else `undefined`.
#### Example
```js
_.findLast([1, 2, 3, 4], function(num) {
return num % 2 == 1;
});
// => 3
```
* * *
### `_.forEach(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3503 "View in source") [Ⓣ][1]
Iterates over elements of a collection, executing the callback for each element. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`.
Note: As with other "Collections" methods, objects with a `length` property are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` may be used for object iteration.
#### Aliases
*_.each*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function)*: The function called per iteration.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array, Object, string)*: Returns `collection`.
#### Example
```js
_([1, 2, 3]).forEach(function(num) { console.log(num); }).join(',');
// => logs each number and returns '1,2,3'
_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
// => logs each number and returns the object (property order is not guaranteed across environments)
```
* * *
### `_.forEachRight(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3536 "View in source") [Ⓣ][1]
This method is like `_.forEach` except that it iterates over elements of a `collection` from right to left.
#### Aliases
*_.eachRight*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function)*: The function called per iteration.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array, Object, string)*: Returns `collection`.
#### Example
```js
_([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(',');
// => logs each number from right to left and returns '3,2,1'
```
* * *
### `_.groupBy(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3597 "View in source") [Ⓣ][1]
Creates an object composed of keys generated from the results of running each element of a collection through the callback. The corresponding value of each key is an array of the elements responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Object)*: Returns the composed aggregate object.
#### Example
```js
_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
// => { '4': [4.2], '6': [6.1, 6.4] }
_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
// => { '4': [4.2], '6': [6.1, 6.4] }
// using "_.pluck" callback shorthand
_.groupBy(['one', 'two', 'three'], 'length');
// => { '3': ['one', 'two'], '5': ['three'] }
```
* * *
### `_.indexBy(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3640 "View in source") [Ⓣ][1]
Creates an object composed of keys generated from the results of running each element of the collection through the given callback. The corresponding value of each key is the last element responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Object)*: Returns the composed aggregate object.
#### Example
```js
var keys = [
{ 'dir': 'left', 'code': 97 },
{ 'dir': 'right', 'code': 100 }
];
_.indexBy(keys, 'dir');
// => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
_.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
// => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
_.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String);
// => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
```
* * *
### `_.invoke(collection, methodName, [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3666 "View in source") [Ⓣ][1]
Invokes the method named by `methodName` on each element in the `collection` returning an array of the results of each invoked method. Additional arguments will be provided to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `methodName` *(Function|string)*: The name of the method to invoke or the function invoked per iteration.
3. `[arg]` *(...\*)*: Arguments to invoke the method with.
#### Returns
*(Array)*: Returns a new array of the results of each invoked method.
#### Example
```js
_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
// => [[1, 5, 7], [1, 2, 3]]
_.invoke([123, 456], String.prototype.split, '');
// => [['1', '2', '3'], ['4', '5', '6']]
```
* * *
### `_.map(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1]
Creates an array of values by running each element in the collection through the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.collect*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a new array of the results of each `callback` execution.
#### Example
```js
_.map([1, 2, 3], function(num) { return num * 3; });
// => [3, 6, 9]
_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
// => [3, 6, 9] (property order is not guaranteed across environments)
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
// using "_.pluck" callback shorthand
_.map(characters, 'name');
// => ['barney', 'fred']
```
* * *
### `_.max(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3776 "View in source") [Ⓣ][1]
Retrieves the maximum value of a collection. If the collection is empty or falsey `-Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the maximum value.
#### Example
```js
_.max([4, 2, 8, 6]);
// => 8
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
_.max(characters, function(chr) { return chr.age; });
// => { 'name': 'fred', 'age': 40 };
// using "_.pluck" callback shorthand
_.max(characters, 'age');
// => { 'name': 'fred', 'age': 40 };
```
* * *
### `_.min(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3846 "View in source") [Ⓣ][1]
Retrieves the minimum value of a collection. If the collection is empty or falsey `Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the minimum value.
#### Example
```js
_.min([4, 2, 8, 6]);
// => 2
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
_.min(characters, function(chr) { return chr.age; });
// => { 'name': 'barney', 'age': 36 };
// using "_.pluck" callback shorthand
_.min(characters, 'age');
// => { 'name': 'barney', 'age': 36 };
```
* * *
### `_.pluck(collection, property)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3896 "View in source") [Ⓣ][1]
Retrieves the value of a specified property from all elements in the collection.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `property` *(string)*: The property to pluck.
#### Returns
*(Array)*: Returns a new array of property values.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
_.pluck(characters, 'name');
// => ['barney', 'fred']
```
* * *
### `_.reduce(collection, [callback=identity], [accumulator], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3928 "View in source") [Ⓣ][1]
Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If `accumulator` is not provided the first element of the collection will be used as the initial `accumulator` value. The callback is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*.
#### Aliases
*_.foldl, _.inject*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function)*: The function called per iteration.
3. `[accumulator]` *(\*)*: Initial value of the accumulator.
4. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the accumulated value.
#### Example
```js
var sum = _.reduce([1, 2, 3], function(sum, num) {
return sum + num;
});
// => 6
var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
result[key] = num * 3;
return result;
}, {});
// => { 'a': 3, 'b': 6, 'c': 9 }
```
* * *
### `_.reduceRight(collection, [callback=identity], [accumulator], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3971 "View in source") [Ⓣ][1]
This method is like `_.reduce` except that it iterates over elements of a `collection` from right to left.
#### Aliases
*_.foldr*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function)*: The function called per iteration.
3. `[accumulator]` *(\*)*: Initial value of the accumulator.
4. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(\*)*: Returns the accumulated value.
#### Example
```js
var list = [[0, 1], [2, 3], [4, 5]];
var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
// => [4, 5, 2, 3, 0, 1]
```
* * *
### `_.reject(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4020 "View in source") [Ⓣ][1]
The opposite of `_.filter` this method returns the elements of a collection that the callback does **not** return truey for.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a new array of elements that failed the callback check.
#### Example
```js
var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
// => [1, 3, 5]
var characters = [
{ 'name': 'barney', 'age': 36, 'blocked': false },
{ 'name': 'fred', 'age': 40, 'blocked': true }
];
// using "_.pluck" callback shorthand
_.reject(characters, 'blocked');
// => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
// using "_.where" callback shorthand
_.reject(characters, { 'age': 36 });
// => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
```
* * *
### `_.sample(collection, [n])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4046 "View in source") [Ⓣ][1]
Retrieves a random element or `n` random elements from a collection.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to sample.
2. `[n]` *(number)*: The number of elements to sample.
#### Returns
*(Array)*: Returns the random sample(s) of `collection`.
#### Example
```js
_.sample([1, 2, 3, 4]);
// => 2
_.sample([1, 2, 3, 4], 2);
// => [3, 1]
```
* * *
### `_.shuffle(collection)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4074 "View in source") [Ⓣ][1]
Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to shuffle.
#### Returns
*(Array)*: Returns a new shuffled collection.
#### Example
```js
_.shuffle([1, 2, 3, 4, 5, 6]);
// => [4, 1, 6, 3, 5, 2]
```
* * *
### `_.size(collection)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4107 "View in source") [Ⓣ][1]
Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to inspect.
#### Returns
*(number)*: Returns `collection.length` or number of own enumerable properties.
#### Example
```js
_.size([1, 2]);
// => 2
_.size({ 'one': 1, 'two': 2, 'three': 3 });
// => 3
_.size('pebbles');
// => 5
```
* * *
### `_.some(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4154 "View in source") [Ⓣ][1]
Checks if the callback returns a truey value for **any** element of a collection. The function returns as soon as it finds a passing value and does not iterate over the entire collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Aliases
*_.any*
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(boolean)*: Returns `true` if any element passed the callback check, else `false`.
#### Example
```js
_.some([null, 0, 'yes', false], Boolean);
// => true
var characters = [
{ 'name': 'barney', 'age': 36, 'blocked': false },
{ 'name': 'fred', 'age': 40, 'blocked': true }
];
// using "_.pluck" callback shorthand
_.some(characters, 'blocked');
// => true
// using "_.where" callback shorthand
_.some(characters, { 'age': 1 });
// => false
```
* * *
### `_.sortBy(collection, [callback=identity], [thisArg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4210 "View in source") [Ⓣ][1]
Creates an array of elements, sorted in ascending order by the results of running each element in a collection through the callback. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(\*)*: The `this` binding of `callback`.
#### Returns
*(Array)*: Returns a new array of sorted elements.
#### Example
```js
_.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
// => [3, 1, 2]
_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
// => [3, 1, 2]
// using "_.pluck" callback shorthand
_.sortBy(['banana', 'strawberry', 'apple'], 'length');
// => ['apple', 'banana', 'strawberry']
```
* * *
### `_.toArray(collection)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4246 "View in source") [Ⓣ][1]
Converts the `collection` to an array.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to convert.
#### Returns
*(Array)*: Returns the new converted array.
#### Example
```js
(function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
// => [2, 3, 4]
```
* * *
### `_.where(collection, properties)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4280 "View in source") [Ⓣ][1]
Performs a deep comparison of each element in a `collection` to the given `properties` object, returning an array of all elements that have equivalent property values.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
2. `properties` *(Object)*: The object of property values to filter by.
#### Returns
*(Array)*: Returns a new array of elements that have the given properties.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] },
{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
];
_.where(characters, { 'age': 36 });
// => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }]
_.where(characters, { 'pets': ['dino'] });
// => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }]
```
* * *
## `“Functions” Methods`
### `_.after(n, func)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5309 "View in source") [Ⓣ][1]
Creates a function that executes `func`, with the `this` binding and arguments of the created function, only after being called `n` times.
#### Arguments
1. `n` *(number)*: The number of times the function must be called before `func` is executed.
2. `func` *(Function)*: The function to restrict.
#### Returns
*(Function)*: Returns the new restricted function.
#### Example
```js
var saves = ['profile', 'settings'];
var done = _.after(saves.length, function() {
console.log('Done saving!');
});
_.forEach(saves, function(type) {
asyncSave({ 'type': type, 'complete': done });
});
// => logs 'Done saving!', after all saves have completed
```
* * *
### `_.bind(func, [thisArg], [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5342 "View in source") [Ⓣ][1]
Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those provided to the bound function.
#### Arguments
1. `func` *(Function)*: The function to bind.
2. `[thisArg]` *(\*)*: The `this` binding of `func`.
3. `[arg]` *(...\*)*: Arguments to be partially applied.
#### Returns
*(Function)*: Returns the new bound function.
#### Example
```js
var func = function(greeting) {
return greeting + ' ' + this.name;
};
func = _.bind(func, { 'name': 'fred' }, 'hi');
func();
// => 'hi fred'
```
* * *
### `_.bindAll(object, [methodName])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5372 "View in source") [Ⓣ][1]
Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided all the function properties of `object` will be bound.
#### Arguments
1. `object` *(Object)*: The object to bind and assign the bound methods to.
2. `[methodName]` *(...string)*: The object method names to bind, specified as individual method names or arrays of method names.
#### Returns
*(Object)*: Returns `object`.
#### Example
```js
var view = {
'label': 'docs',
'onClick': function() { console.log('clicked ' + this.label); }
};
_.bindAll(view);
jQuery('#docs').on('click', view.onClick);
// => logs 'clicked docs', when the button is clicked
```
* * *
### `_.bindKey(object, key, [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5418 "View in source") [Ⓣ][1]
Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those provided to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern.
#### Arguments
1. `object` *(Object)*: The object the method belongs to.
2. `key` *(string)*: The key of the method.
3. `[arg]` *(...\*)*: Arguments to be partially applied.
#### Returns
*(Function)*: Returns the new bound function.
#### Example
```js
var object = {
'name': 'fred',
'greet': function(greeting) {
return greeting + ' ' + this.name;
}
};
var func = _.bindKey(object, 'greet', 'hi');
func();
// => 'hi fred'
object.greet = function(greeting) {
return greeting + 'ya ' + this.name + '!';
};
func();
// => 'hiya fred!'
```
* * *
### `_.compose([func])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5454 "View in source") [Ⓣ][1]
Creates a function that is the composition of the provided functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function.
#### Arguments
1. `[func]` *(...Function)*: Functions to compose.
#### Returns
*(Function)*: Returns the new composed function.
#### Example
```js
var realNameMap = {
'pebbles': 'jerome'
};
var format = function(name) {
name = realNameMap[name.toLowerCase()] || name;
return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
};
var greet = function(formatted) {
return 'Hiya ' + formatted + '!';
};
var welcome = _.compose(greet, format);
welcome('pebbles');
// => 'Hiya Jerome!'
```
* * *
### `_.createCallback([func=identity], [thisArg], [argCount])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5505 "View in source") [Ⓣ][1]
Produces a callback bound to an optional `thisArg`. If `func` is a property name the created callback will return the property value for a given element. If `func` is an object the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`.
#### Arguments
1. `[func=identity]` *(\*)*: The value to convert to a callback.
2. `[thisArg]` *(\*)*: The `this` binding of the created callback.
3. `[argCount]` *(number)*: The number of arguments the callback accepts.
#### Returns
*(Function)*: Returns a callback function.
#### Example
```js
var characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
// wrap to create custom callback shorthands
_.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
return !match ? func(callback, thisArg) : function(object) {
return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
};
});
_.filter(characters, 'age__gt38');
// => [{ 'name': 'fred', 'age': 40 }]
```
* * *
### `_.curry(func, [arity=func.length])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5570 "View in source") [Ⓣ][1]
Creates a function which accepts one or more arguments of `func` that when invoked either executes `func` returning its result, if all `func` arguments have been provided, or returns a function that accepts one or more of the remaining `func` arguments, and so on. The arity of `func` can be specified if `func.length` is not sufficient.
#### Arguments
1. `func` *(Function)*: The function to curry.
2. `[arity=func.length]` *(number)*: The arity of `func`.
#### Returns
*(Function)*: Returns the new curried function.
#### Example
```js
var curried = _.curry(function(a, b, c) {
console.log(a + b + c);
});
curried(1)(2)(3);
// => 6
curried(1, 2)(3);
// => 6
curried(1, 2, 3);
// => 6
```
* * *
### `_.debounce(func, wait, [options], [options.maxWait])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5614 "View in source") [Ⓣ][1]
Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call.
Note: If `leading` and `trailing` options are `true` `func` will be called on the trailing edge of the timeout only if the the debounced function is invoked more than once during the `wait` timeout.
#### Arguments
1. `func` *(Function)*: The function to debounce.
2. `wait` *(number)*: The number of milliseconds to delay.
3. `[options]` *(Object)*: The options object.
4. `[options.leading=false]` *(boolean)*: Specify execution on the leading edge of the timeout.
5. `[options.maxWait]` *(number)*: The maximum time `func` is allowed to be delayed before it's called.
6. `[options.trailing=true]` *(boolean)*: Specify execution on the trailing edge of the timeout.
#### Returns
*(Function)*: Returns the new debounced function.
#### Example
```js
// avoid costly calculations while the window size is in flux
var lazyLayout = _.debounce(calculateLayout, 150);
jQuery(window).on('resize', lazyLayout);
// execute `sendMail` when the click event is fired, debouncing subsequent calls
jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
'leading': true,
'trailing': false
});
// ensure `batchLog` is executed once after 1 second of debounced calls
var source = new EventSource('/stream');
source.addEventListener('message', _.debounce(batchLog, 250, {
'maxWait': 1000
}, false);
```
* * *
### `_.defer(func, [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5715 "View in source") [Ⓣ][1]
Defers executing the `func` function until the current call stack has cleared. Additional arguments will be provided to `func` when it is invoked.
#### Arguments
1. `func` *(Function)*: The function to defer.
2. `[arg]` *(...\*)*: Arguments to invoke the function with.
#### Returns
*(number)*: Returns the timer id.
#### Example
```js
_.defer(function() { console.log('deferred'); });
// returns from the function before 'deferred' is logged
```
* * *
### `_.delay(func, wait, [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5749 "View in source") [Ⓣ][1]
Executes the `func` function after `wait` milliseconds. Additional arguments will be provided to `func` when it is invoked.
#### Arguments
1. `func` *(Function)*: The function to delay.
2. `wait` *(number)*: The number of milliseconds to delay execution.
3. `[arg]` *(...\*)*: Arguments to invoke the function with.
#### Returns
*(number)*: Returns the timer id.
#### Example
```js
var log = _.bind(console.log, console);
_.delay(log, 1000, 'logged later');
// => 'logged later' (Appears after one second.)
```
* * *
### `_.memoize(func, [resolver])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5791 "View in source") [Ⓣ][1]
Creates a function that memoizes the result of `func`. If `resolver` is provided it will be used to determine the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. The result cache is exposed as the `cache` property on the memoized function.
#### Arguments
1. `func` *(Function)*: The function to have its output memoized.
2. `[resolver]` *(Function)*: A function used to resolve the cache key.
#### Returns
*(Function)*: Returns the new memoizing function.
#### Example
```js
var fibonacci = _.memoize(function(n) {
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
});
var data = {
'fred': { 'name': 'fred', 'age': 40 },
'pebbles': { 'name': 'pebbles', 'age': 60 }
};
// modifying the result cache
var stooge = _.memoize(function(name) { return data[name]; }, _.identity);
stooge('pebbles');
// => { 'name': 'pebbles', 'age': 60 }
stooge.cache.pebbles.name = 'jerome';
stooge('pebbles');
// => { 'name': 'jerome', 'age': 60 }
```
* * *
### `_.once(func)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5824 "View in source") [Ⓣ][1]
Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function.
#### Arguments
1. `func` *(Function)*: The function to restrict.
#### Returns
*(Function)*: Returns the new restricted function.
#### Example
```js
var initialize = _.once(createApplication);
initialize();
initialize();
// `initialize` executes `createApplication` once
```
* * *
### `_.partial(func, [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5862 "View in source") [Ⓣ][1]
Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those provided to the new function. This method is similar to `_.bind` except it does **not** alter the `this` binding.
#### Arguments
1. `func` *(Function)*: The function to partially apply arguments to.
2. `[arg]` *(...\*)*: Arguments to be partially applied.
#### Returns
*(Function)*: Returns the new partially applied function.
#### Example
```js
var greet = function(greeting, name) { return greeting + ' ' + name; };
var hi = _.partial(greet, 'hi');
hi('fred');
// => 'hi fred'
```
* * *
### `_.partialRight(func, [arg])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5893 "View in source") [Ⓣ][1]
This method is like `_.partial` except that `partial` arguments are appended to those provided to the new function.
#### Arguments
1. `func` *(Function)*: The function to partially apply arguments to.
2. `[arg]` *(...\*)*: Arguments to be partially applied.
#### Returns
*(Function)*: Returns the new partially applied function.
#### Example
```js
var defaultsDeep = _.partialRight(_.merge, _.defaults);
var options = {
'variable': 'data',
'imports': { 'jq': $ }
};
defaultsDeep(options, _.templateSettings);
options.variable
// => 'data'
options.imports
// => { '_': _, 'jq': $ }
```
* * *
### `_.throttle(func, wait, [options])`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5928 "View in source") [Ⓣ][1]
Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call.
Note: If `leading` and `trailing` options are `true` `func` will be called on the trailing edge of the timeout only if the the throttled function is invoked more than once during the `wait` timeout.
#### Arguments
1. `func` *(Function)*: The function to throttle.
2. `wait` *(number)*: The number of milliseconds to throttle executions to.
3. `[options]` *(Object)*: The options object.
4. `[options.leading=true]` *(boolean)*: Specify execution on the leading edge of the timeout.
5. `[options.trailing=true]` *(boolean)*: Specify execution on the trailing edge of the timeout.
#### Returns
*(Function)*: Returns the new throttled function.
#### Example
```js
// avoid excessively updating the position while scrolling
var throttled = _.throttle(updatePosition, 100);
jQuery(window).on('scroll', throttled);
// execute `renewToken` when the click event is fired, but not more than once every 5 minutes
jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
'trailing': false
}));
```
* * *
### `_.wrap(value, wrapper)`
# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5968 "View in source") [Ⓣ][1]
Creates a function that provides `value` to the wrapper function as its first argument. Additional arguments provided to the function are appended to those provided to the wrapper function. The wrapper is executed with the `this` binding of the created function.
#### Arguments
1. `value` *(\*)*: The value to wrap.
2. `wrapper` *(Function)*: The wrapper function.
#### Returns
*(Function)*: Returns the new function.
#### Example
```js
var pre= _.wrap(_.escape, function(func, text) {
return '