PageRenderTime 58ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/slider/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/doc/README.md

https://bitbucket.org/kristijanhusak/koaslider
Markdown | 3590 lines | 2375 code | 1215 blank | 0 comment | 0 complexity | a71626c79bf93a5ff610106e395bc913 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT
  1. # Lo-Dash <sup>v1.0.1</sup>
  2. <!-- div -->
  3. <!-- div -->
  4. ## <a id="Arrays"></a>`Arrays`
  5. * [`_.compact`](#_compactarray)
  6. * [`_.difference`](#_differencearray--array1-array2-)
  7. * [`_.drop`](#_restarray--callbackn1-thisarg)
  8. * [`_.first`](#_firstarray--callbackn-thisarg)
  9. * [`_.flatten`](#_flattenarray-shallow)
  10. * [`_.head`](#_firstarray--callbackn-thisarg)
  11. * [`_.indexOf`](#_indexofarray-value--fromindex0)
  12. * [`_.initial`](#_initialarray--callbackn1-thisarg)
  13. * [`_.intersection`](#_intersectionarray1-array2-)
  14. * [`_.last`](#_lastarray--callbackn-thisarg)
  15. * [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1)
  16. * [`_.object`](#_objectkeys--values)
  17. * [`_.range`](#_rangestart0-end--step1)
  18. * [`_.rest`](#_restarray--callbackn1-thisarg)
  19. * [`_.sortedIndex`](#_sortedindexarray-value--callbackidentity-thisarg)
  20. * [`_.tail`](#_restarray--callbackn1-thisarg)
  21. * [`_.take`](#_firstarray--callbackn-thisarg)
  22. * [`_.union`](#_unionarray1-array2-)
  23. * [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg)
  24. * [`_.unique`](#_uniqarray--issortedfalse-callbackidentity-thisarg)
  25. * [`_.without`](#_withoutarray--value1-value2-)
  26. * [`_.zip`](#_ziparray1-array2-)
  27. <!-- /div -->
  28. <!-- div -->
  29. ## `Chaining`
  30. * [`_`](#_value)
  31. * [`_.tap`](#_tapvalue-interceptor)
  32. * [`_.prototype.toString`](#_prototypetostring)
  33. * [`_.prototype.value`](#_prototypevalueof)
  34. * [`_.prototype.valueOf`](#_prototypevalueof)
  35. <!-- /div -->
  36. <!-- div -->
  37. ## `Collections`
  38. * [`_.all`](#_everycollection--callbackidentity-thisarg)
  39. * [`_.any`](#_somecollection--callbackidentity-thisarg)
  40. * [`_.at`](#_atcollection--index1-index2-)
  41. * [`_.collect`](#_mapcollection--callbackidentity-thisarg)
  42. * [`_.contains`](#_containscollection-target--fromindex0)
  43. * [`_.countBy`](#_countbycollection--callbackidentity-thisarg)
  44. * [`_.detect`](#_findcollection--callbackidentity-thisarg)
  45. * [`_.each`](#_foreachcollection--callbackidentity-thisarg)
  46. * [`_.every`](#_everycollection--callbackidentity-thisarg)
  47. * [`_.filter`](#_filtercollection--callbackidentity-thisarg)
  48. * [`_.find`](#_findcollection--callbackidentity-thisarg)
  49. * [`_.foldl`](#_reducecollection--callbackidentity-accumulator-thisarg)
  50. * [`_.foldr`](#_reducerightcollection--callbackidentity-accumulator-thisarg)
  51. * [`_.forEach`](#_foreachcollection--callbackidentity-thisarg)
  52. * [`_.groupBy`](#_groupbycollection--callbackidentity-thisarg)
  53. * [`_.include`](#_containscollection-target--fromindex0)
  54. * [`_.inject`](#_reducecollection--callbackidentity-accumulator-thisarg)
  55. * [`_.invoke`](#_invokecollection-methodname--arg1-arg2-)
  56. * [`_.map`](#_mapcollection--callbackidentity-thisarg)
  57. * [`_.max`](#_maxcollection--callbackidentity-thisarg)
  58. * [`_.min`](#_mincollection--callbackidentity-thisarg)
  59. * [`_.pluck`](#_pluckcollection-property)
  60. * [`_.reduce`](#_reducecollection--callbackidentity-accumulator-thisarg)
  61. * [`_.reduceRight`](#_reducerightcollection--callbackidentity-accumulator-thisarg)
  62. * [`_.reject`](#_rejectcollection--callbackidentity-thisarg)
  63. * [`_.select`](#_filtercollection--callbackidentity-thisarg)
  64. * [`_.shuffle`](#_shufflecollection)
  65. * [`_.size`](#_sizecollection)
  66. * [`_.some`](#_somecollection--callbackidentity-thisarg)
  67. * [`_.sortBy`](#_sortbycollection--callbackidentity-thisarg)
  68. * [`_.toArray`](#_toarraycollection)
  69. * [`_.where`](#_wherecollection-properties)
  70. <!-- /div -->
  71. <!-- div -->
  72. ## `Functions`
  73. * [`_.after`](#_aftern-func)
  74. * [`_.bind`](#_bindfunc--thisarg-arg1-arg2-)
  75. * [`_.bindAll`](#_bindallobject--methodname1-methodname2-)
  76. * [`_.bindKey`](#_bindkeyobject-key--arg1-arg2-)
  77. * [`_.compose`](#_composefunc1-func2-)
  78. * [`_.debounce`](#_debouncefunc-wait-immediate)
  79. * [`_.defer`](#_deferfunc--arg1-arg2-)
  80. * [`_.delay`](#_delayfunc-wait--arg1-arg2-)
  81. * [`_.memoize`](#_memoizefunc--resolver)
  82. * [`_.once`](#_oncefunc)
  83. * [`_.partial`](#_partialfunc--arg1-arg2-)
  84. * [`_.partialRight`](#_partialrightfunc--arg1-arg2-)
  85. * [`_.throttle`](#_throttlefunc-wait)
  86. * [`_.wrap`](#_wrapvalue-wrapper)
  87. <!-- /div -->
  88. <!-- div -->
  89. ## `Objects`
  90. * [`_.assign`](#_assignobject--source1-source2--callback-thisarg)
  91. * [`_.clone`](#_clonevalue--deepfalse-callback-thisarg)
  92. * [`_.cloneDeep`](#_clonedeepvalue--callback-thisarg)
  93. * [`_.defaults`](#_defaultsobject--source1-source2-)
  94. * [`_.extend`](#_assignobject--source1-source2--callback-thisarg)
  95. * [`_.forIn`](#_forinobject--callbackidentity-thisarg)
  96. * [`_.forOwn`](#_forownobject--callbackidentity-thisarg)
  97. * [`_.functions`](#_functionsobject)
  98. * [`_.has`](#_hasobject-property)
  99. * [`_.invert`](#_invertobject)
  100. * [`_.isArguments`](#_isargumentsvalue)
  101. * [`_.isArray`](#_isarrayvalue)
  102. * [`_.isBoolean`](#_isbooleanvalue)
  103. * [`_.isDate`](#_isdatevalue)
  104. * [`_.isElement`](#_iselementvalue)
  105. * [`_.isEmpty`](#_isemptyvalue)
  106. * [`_.isEqual`](#_isequala-b--callback-thisarg)
  107. * [`_.isFinite`](#_isfinitevalue)
  108. * [`_.isFunction`](#_isfunctionvalue)
  109. * [`_.isNaN`](#_isnanvalue)
  110. * [`_.isNull`](#_isnullvalue)
  111. * [`_.isNumber`](#_isnumbervalue)
  112. * [`_.isObject`](#_isobjectvalue)
  113. * [`_.isPlainObject`](#_isplainobjectvalue)
  114. * [`_.isRegExp`](#_isregexpvalue)
  115. * [`_.isString`](#_isstringvalue)
  116. * [`_.isUndefined`](#_isundefinedvalue)
  117. * [`_.keys`](#_keysobject)
  118. * [`_.merge`](#_mergeobject--source1-source2--callback-thisarg)
  119. * [`_.methods`](#_functionsobject)
  120. * [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg)
  121. * [`_.pairs`](#_pairsobject)
  122. * [`_.pick`](#_pickobject-callback-prop1-prop2--thisarg)
  123. * [`_.values`](#_valuesobject)
  124. <!-- /div -->
  125. <!-- div -->
  126. ## `Utilities`
  127. * [`_.escape`](#_escapestring)
  128. * [`_.identity`](#_identityvalue)
  129. * [`_.mixin`](#_mixinobject)
  130. * [`_.noConflict`](#_noconflict)
  131. * [`_.random`](#_randommin0-max1)
  132. * [`_.result`](#_resultobject-property)
  133. * [`_.template`](#_templatetext-data-options)
  134. * [`_.times`](#_timesn-callback--thisarg)
  135. * [`_.unescape`](#_unescapestring)
  136. * [`_.uniqueId`](#_uniqueidprefix)
  137. <!-- /div -->
  138. <!-- div -->
  139. ## `Methods`
  140. * [`_.templateSettings.imports._`](#_templatesettingsimports_)
  141. <!-- /div -->
  142. <!-- div -->
  143. ## `Properties`
  144. * [`_.VERSION`](#_version)
  145. * [`_.templateSettings`](#_templatesettings)
  146. * [`_.templateSettings.escape`](#_templatesettingsescape)
  147. * [`_.templateSettings.evaluate`](#_templatesettingsevaluate)
  148. * [`_.templateSettings.interpolate`](#_templatesettingsinterpolate)
  149. * [`_.templateSettings.variable`](#_templatesettingsvariable)
  150. * [`_.templateSettings.imports`](#_templatesettingsimports)
  151. <!-- /div -->
  152. <!-- /div -->
  153. <!-- div -->
  154. <!-- div -->
  155. ## `“Arrays” Methods`
  156. <!-- div -->
  157. ### <a id="_compactarray"></a>`_.compact(array)`
  158. <a href="#_compactarray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3166 "View in source") [&#x24C9;][1]
  159. Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
  160. #### Arguments
  161. 1. `array` *(Array)*: The array to compact.
  162. #### Returns
  163. *(Array)*: Returns a new filtered array.
  164. #### Example
  165. ```js
  166. _.compact([0, 1, false, 2, '', 3]);
  167. // => [1, 2, 3]
  168. ```
  169. * * *
  170. <!-- /div -->
  171. <!-- div -->
  172. ### <a id="_differencearray--array1-array2-"></a>`_.difference(array [, array1, array2, ...])`
  173. <a href="#_differencearray--array1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3196 "View in source") [&#x24C9;][1]
  174. Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`.
  175. #### Arguments
  176. 1. `array` *(Array)*: The array to process.
  177. 2. `[array1, array2, ...]` *(Array)*: Arrays to check.
  178. #### Returns
  179. *(Array)*: Returns a new array of `array` elements not present in the other arrays.
  180. #### Example
  181. ```js
  182. _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
  183. // => [1, 3, 4]
  184. ```
  185. * * *
  186. <!-- /div -->
  187. <!-- div -->
  188. ### <a id="_firstarray--callbackn-thisarg"></a>`_.first(array [, callback|n, thisArg])`
  189. <a href="#_firstarray--callbackn-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3268 "View in source") [&#x24C9;][1]
  190. Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
  191. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  192. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  193. #### Aliases
  194. *head, take*
  195. #### Arguments
  196. 1. `array` *(Array)*: The array to query.
  197. 2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  198. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  199. #### Returns
  200. *(Mixed)*: Returns the first element(s) of `array`.
  201. #### Example
  202. ```js
  203. _.first([1, 2, 3]);
  204. // => 1
  205. _.first([1, 2, 3], 2);
  206. // => [1, 2]
  207. _.first([1, 2, 3], function(num) {
  208. return num < 3;
  209. });
  210. // => [1, 2]
  211. var food = [
  212. { 'name': 'banana', 'organic': true },
  213. { 'name': 'beet', 'organic': false },
  214. ];
  215. // using "_.pluck" callback shorthand
  216. _.first(food, 'organic');
  217. // => [{ 'name': 'banana', 'organic': true }]
  218. var food = [
  219. { 'name': 'apple', 'type': 'fruit' },
  220. { 'name': 'banana', 'type': 'fruit' },
  221. { 'name': 'beet', 'type': 'vegetable' }
  222. ];
  223. // using "_.where" callback shorthand
  224. _.first(food, { 'type': 'fruit' });
  225. // => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }]
  226. ```
  227. * * *
  228. <!-- /div -->
  229. <!-- div -->
  230. ### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)`
  231. <a href="#_flattenarray-shallow">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [&#x24C9;][1]
  232. Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level.
  233. #### Arguments
  234. 1. `array` *(Array)*: The array to compact.
  235. 2. `shallow` *(Boolean)*: A flag to indicate only flattening a single level.
  236. #### Returns
  237. *(Array)*: Returns a new flattened array.
  238. #### Example
  239. ```js
  240. _.flatten([1, [2], [3, [[4]]]]);
  241. // => [1, 2, 3, 4];
  242. _.flatten([1, [2], [3, [[4]]]], true);
  243. // => [1, 2, 3, [[4]]];
  244. ```
  245. * * *
  246. <!-- /div -->
  247. <!-- div -->
  248. ### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])`
  249. <a href="#_indexofarray-value--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "View in source") [&#x24C9;][1]
  250. 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, passing `true` for `fromIndex` will run a faster binary search.
  251. #### Arguments
  252. 1. `array` *(Array)*: The array to search.
  253. 2. `value` *(Mixed)*: The value to search for.
  254. 3. `[fromIndex=0]` *(Boolean|Number)*: The index to search from or `true` to perform a binary search on a sorted `array`.
  255. #### Returns
  256. *(Number)*: Returns the index of the matched value or `-1`.
  257. #### Example
  258. ```js
  259. _.indexOf([1, 2, 3, 1, 2, 3], 2);
  260. // => 1
  261. _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
  262. // => 4
  263. _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
  264. // => 2
  265. ```
  266. * * *
  267. <!-- /div -->
  268. <!-- div -->
  269. ### <a id="_initialarray--callbackn1-thisarg"></a>`_.initial(array [, callback|n=1, thisArg])`
  270. <a href="#_initialarray--callbackn1-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3423 "View in source") [&#x24C9;][1]
  271. Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
  272. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  273. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  274. #### Arguments
  275. 1. `array` *(Array)*: The array to query.
  276. 2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  277. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  278. #### Returns
  279. *(Array)*: Returns a slice of `array`.
  280. #### Example
  281. ```js
  282. _.initial([1, 2, 3]);
  283. // => [1, 2]
  284. _.initial([1, 2, 3], 2);
  285. // => [1]
  286. _.initial([1, 2, 3], function(num) {
  287. return num > 1;
  288. });
  289. // => [1]
  290. var food = [
  291. { 'name': 'beet', 'organic': false },
  292. { 'name': 'carrot', 'organic': true }
  293. ];
  294. // using "_.pluck" callback shorthand
  295. _.initial(food, 'organic');
  296. // => [{ 'name': 'beet', 'organic': false }]
  297. var food = [
  298. { 'name': 'banana', 'type': 'fruit' },
  299. { 'name': 'beet', 'type': 'vegetable' },
  300. { 'name': 'carrot', 'type': 'vegetable' }
  301. ];
  302. // using "_.where" callback shorthand
  303. _.initial(food, { 'type': 'vegetable' });
  304. // => [{ 'name': 'banana', 'type': 'fruit' }]
  305. ```
  306. * * *
  307. <!-- /div -->
  308. <!-- div -->
  309. ### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])`
  310. <a href="#_intersectionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [&#x24C9;][1]
  311. Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`.
  312. #### Arguments
  313. 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
  314. #### Returns
  315. *(Array)*: Returns a new array of unique elements that are present in **all** of the arrays.
  316. #### Example
  317. ```js
  318. _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
  319. // => [1, 2]
  320. ```
  321. * * *
  322. <!-- /div -->
  323. <!-- div -->
  324. ### <a id="_lastarray--callbackn-thisarg"></a>`_.last(array [, callback|n, thisArg])`
  325. <a href="#_lastarray--callbackn-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "View in source") [&#x24C9;][1]
  326. Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
  327. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  328. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  329. #### Arguments
  330. 1. `array` *(Array)*: The array to query.
  331. 2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  332. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  333. #### Returns
  334. *(Mixed)*: Returns the last element(s) of `array`.
  335. #### Example
  336. ```js
  337. _.last([1, 2, 3]);
  338. // => 3
  339. _.last([1, 2, 3], 2);
  340. // => [2, 3]
  341. _.last([1, 2, 3], function(num) {
  342. return num > 1;
  343. });
  344. // => [2, 3]
  345. var food = [
  346. { 'name': 'beet', 'organic': false },
  347. { 'name': 'carrot', 'organic': true }
  348. ];
  349. // using "_.pluck" callback shorthand
  350. _.last(food, 'organic');
  351. // => [{ 'name': 'carrot', 'organic': true }]
  352. var food = [
  353. { 'name': 'banana', 'type': 'fruit' },
  354. { 'name': 'beet', 'type': 'vegetable' },
  355. { 'name': 'carrot', 'type': 'vegetable' }
  356. ];
  357. // using "_.where" callback shorthand
  358. _.last(food, { 'type': 'vegetable' });
  359. // => [{ 'name': 'beet', 'type': 'vegetable' }, { 'name': 'carrot', 'type': 'vegetable' }]
  360. ```
  361. * * *
  362. <!-- /div -->
  363. <!-- div -->
  364. ### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])`
  365. <a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3589 "View in source") [&#x24C9;][1]
  366. 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.
  367. #### Arguments
  368. 1. `array` *(Array)*: The array to search.
  369. 2. `value` *(Mixed)*: The value to search for.
  370. 3. `[fromIndex=array.length-1]` *(Number)*: The index to search from.
  371. #### Returns
  372. *(Number)*: Returns the index of the matched value or `-1`.
  373. #### Example
  374. ```js
  375. _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
  376. // => 4
  377. _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
  378. // => 1
  379. ```
  380. * * *
  381. <!-- /div -->
  382. <!-- div -->
  383. ### <a id="_objectkeys--values"></a>`_.object(keys [, values=[]])`
  384. <a href="#_objectkeys--values">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3619 "View in source") [&#x24C9;][1]
  385. Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`.
  386. #### Arguments
  387. 1. `keys` *(Array)*: The array of keys.
  388. 2. `[values=[]]` *(Array)*: The array of values.
  389. #### Returns
  390. *(Object)*: Returns an object composed of the given keys and corresponding values.
  391. #### Example
  392. ```js
  393. _.object(['moe', 'larry'], [30, 40]);
  394. // => { 'moe': 30, 'larry': 40 }
  395. ```
  396. * * *
  397. <!-- /div -->
  398. <!-- div -->
  399. ### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])`
  400. <a href="#_rangestart0-end--step1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [&#x24C9;][1]
  401. Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`.
  402. #### Arguments
  403. 1. `[start=0]` *(Number)*: The start of the range.
  404. 2. `end` *(Number)*: The end of the range.
  405. 3. `[step=1]` *(Number)*: The value to increment or descrement by.
  406. #### Returns
  407. *(Array)*: Returns a new range array.
  408. #### Example
  409. ```js
  410. _.range(10);
  411. // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  412. _.range(1, 11);
  413. // => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  414. _.range(0, 30, 5);
  415. // => [0, 5, 10, 15, 20, 25]
  416. _.range(0, -10, -1);
  417. // => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
  418. _.range(0);
  419. // => []
  420. ```
  421. * * *
  422. <!-- /div -->
  423. <!-- div -->
  424. ### <a id="_restarray--callbackn1-thisarg"></a>`_.rest(array [, callback|n=1, thisArg])`
  425. <a href="#_restarray--callbackn1-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3741 "View in source") [&#x24C9;][1]
  426. The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
  427. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  428. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  429. #### Aliases
  430. *drop, tail*
  431. #### Arguments
  432. 1. `array` *(Array)*: The array to query.
  433. 2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  434. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  435. #### Returns
  436. *(Array)*: Returns a slice of `array`.
  437. #### Example
  438. ```js
  439. _.rest([1, 2, 3]);
  440. // => [2, 3]
  441. _.rest([1, 2, 3], 2);
  442. // => [3]
  443. _.rest([1, 2, 3], function(num) {
  444. return num < 3;
  445. });
  446. // => [3]
  447. var food = [
  448. { 'name': 'banana', 'organic': true },
  449. { 'name': 'beet', 'organic': false },
  450. ];
  451. // using "_.pluck" callback shorthand
  452. _.rest(food, 'organic');
  453. // => [{ 'name': 'beet', 'organic': false }]
  454. var food = [
  455. { 'name': 'apple', 'type': 'fruit' },
  456. { 'name': 'banana', 'type': 'fruit' },
  457. { 'name': 'beet', 'type': 'vegetable' }
  458. ];
  459. // using "_.where" callback shorthand
  460. _.rest(food, { 'type': 'fruit' });
  461. // => [{ 'name': 'beet', 'type': 'vegetable' }]
  462. ```
  463. * * *
  464. <!-- /div -->
  465. <!-- div -->
  466. ### <a id="_sortedindexarray-value--callbackidentity-thisarg"></a>`_.sortedIndex(array, value [, callback=identity, thisArg])`
  467. <a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3805 "View in source") [&#x24C9;][1]
  468. Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*.
  469. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  470. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  471. #### Arguments
  472. 1. `array` *(Array)*: The array to iterate over.
  473. 2. `value` *(Mixed)*: The value to evaluate.
  474. 3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  475. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  476. #### Returns
  477. *(Number)*: Returns the index at which the value should be inserted into `array`.
  478. #### Example
  479. ```js
  480. _.sortedIndex([20, 30, 50], 40);
  481. // => 2
  482. // using "_.pluck" callback shorthand
  483. _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
  484. // => 2
  485. var dict = {
  486. 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
  487. };
  488. _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
  489. return dict.wordToNumber[word];
  490. });
  491. // => 2
  492. _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
  493. return this.wordToNumber[word];
  494. }, dict);
  495. // => 2
  496. ```
  497. * * *
  498. <!-- /div -->
  499. <!-- div -->
  500. ### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])`
  501. <a href="#_unionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "View in source") [&#x24C9;][1]
  502. Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`.
  503. #### Arguments
  504. 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
  505. #### Returns
  506. *(Array)*: Returns a new array of unique values, in order, that are present in one or more of the arrays.
  507. #### Example
  508. ```js
  509. _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
  510. // => [1, 2, 3, 101, 10]
  511. ```
  512. * * *
  513. <!-- /div -->
  514. <!-- div -->
  515. ### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])`
  516. <a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3884 "View in source") [&#x24C9;][1]
  517. Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
  518. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  519. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  520. #### Aliases
  521. *unique*
  522. #### Arguments
  523. 1. `array` *(Array)*: The array to process.
  524. 2. `[isSorted=false]` *(Boolean)*: A flag to indicate that the `array` is already sorted.
  525. 3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  526. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  527. #### Returns
  528. *(Array)*: Returns a duplicate-value-free array.
  529. #### Example
  530. ```js
  531. _.uniq([1, 2, 1, 3, 1]);
  532. // => [1, 2, 3]
  533. _.uniq([1, 1, 2, 2, 3], true);
  534. // => [1, 2, 3]
  535. _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); });
  536. // => [1, 2, 3]
  537. _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
  538. // => [1, 2, 3]
  539. // using "_.pluck" callback shorthand
  540. _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  541. // => [{ 'x': 1 }, { 'x': 2 }]
  542. ```
  543. * * *
  544. <!-- /div -->
  545. <!-- div -->
  546. ### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])`
  547. <a href="#_withoutarray--value1-value2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3943 "View in source") [&#x24C9;][1]
  548. Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
  549. #### Arguments
  550. 1. `array` *(Array)*: The array to filter.
  551. 2. `[value1, value2, ...]` *(Mixed)*: Values to remove.
  552. #### Returns
  553. *(Array)*: Returns a new filtered array.
  554. #### Example
  555. ```js
  556. _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
  557. // => [2, 3, 4]
  558. ```
  559. * * *
  560. <!-- /div -->
  561. <!-- div -->
  562. ### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])`
  563. <a href="#_ziparray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "View in source") [&#x24C9;][1]
  564. Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion.
  565. #### Arguments
  566. 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
  567. #### Returns
  568. *(Array)*: Returns a new array of grouped elements.
  569. #### Example
  570. ```js
  571. _.zip(['moe', 'larry'], [30, 40], [true, false]);
  572. // => [['moe', 30, true], ['larry', 40, false]]
  573. ```
  574. * * *
  575. <!-- /div -->
  576. <!-- /div -->
  577. <!-- div -->
  578. ## `Chaining Methods`
  579. <!-- div -->
  580. ### <a id="_value"></a>`_(value)`
  581. <a href="#_value">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L272 "View in source") [&#x24C9;][1]
  582. Creates a `lodash` object, that wraps the given `value`, to enable method chaining.
  583. In addition to Lo-Dash methods, wrappers also have the following `Array` methods:<br>
  584. `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, and `unshift`
  585. The chainable wrapper functions are:<br>
  586. `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
  587. The non-chainable wrapper functions are:<br>
  588. `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId`
  589. The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values.
  590. #### Arguments
  591. 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance.
  592. #### Returns
  593. *(Object)*: Returns a `lodash` instance.
  594. * * *
  595. <!-- /div -->
  596. <!-- div -->
  597. ### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
  598. <a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4874 "View in source") [&#x24C9;][1]
  599. 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.
  600. #### Arguments
  601. 1. `value` *(Mixed)*: The value to pass to `interceptor`.
  602. 2. `interceptor` *(Function)*: The function to invoke.
  603. #### Returns
  604. *(Mixed)*: Returns `value`.
  605. #### Example
  606. ```js
  607. _([1, 2, 3, 4])
  608. .filter(function(num) { return num % 2 == 0; })
  609. .tap(alert)
  610. .map(function(num) { return num * num; })
  611. .value();
  612. // => // [2, 4] (alerted)
  613. // => [4, 16]
  614. ```
  615. * * *
  616. <!-- /div -->
  617. <!-- div -->
  618. ### <a id="_prototypetostring"></a>`_.prototype.toString()`
  619. <a href="#_prototypetostring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4891 "View in source") [&#x24C9;][1]
  620. Produces the `toString` result of the wrapped value.
  621. #### Returns
  622. *(String)*: Returns the string result.
  623. #### Example
  624. ```js
  625. _([1, 2, 3]).toString();
  626. // => '1,2,3'
  627. ```
  628. * * *
  629. <!-- /div -->
  630. <!-- div -->
  631. ### <a id="_prototypevalueof"></a>`_.prototype.valueOf()`
  632. <a href="#_prototypevalueof">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4908 "View in source") [&#x24C9;][1]
  633. Extracts the wrapped value.
  634. #### Aliases
  635. *value*
  636. #### Returns
  637. *(Mixed)*: Returns the wrapped value.
  638. #### Example
  639. ```js
  640. _([1, 2, 3]).valueOf();
  641. // => [1, 2, 3]
  642. ```
  643. * * *
  644. <!-- /div -->
  645. <!-- /div -->
  646. <!-- div -->
  647. ## `Collections Methods`
  648. <!-- div -->
  649. ### <a id="_atcollection--index1-index2-"></a>`_.at(collection [, index1, index2, ...])`
  650. <a href="#_atcollection--index1-index2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2167 "View in source") [&#x24C9;][1]
  651. 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.
  652. #### Arguments
  653. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  654. 2. `[index1, index2, ...]` *(Array|Number|String)*: The indexes of `collection` to retrieve, either as individual arguments or arrays.
  655. #### Returns
  656. *(Array)*: Returns a new array of elements corresponding to the provided indexes.
  657. #### Example
  658. ```js
  659. _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
  660. // => ['a', 'c', 'e']
  661. _.at(['moe', 'larry', 'curly'], 0, 2);
  662. // => ['moe', 'curly']
  663. ```
  664. * * *
  665. <!-- /div -->
  666. <!-- div -->
  667. ### <a id="_containscollection-target--fromindex0"></a>`_.contains(collection, target [, fromIndex=0])`
  668. <a href="#_containscollection-target--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2209 "View in source") [&#x24C9;][1]
  669. Checks if a given `target` element 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.
  670. #### Aliases
  671. *include*
  672. #### Arguments
  673. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  674. 2. `target` *(Mixed)*: The value to check for.
  675. 3. `[fromIndex=0]` *(Number)*: The index to search from.
  676. #### Returns
  677. *(Boolean)*: Returns `true` if the `target` element is found, else `false`.
  678. #### Example
  679. ```js
  680. _.contains([1, 2, 3], 1);
  681. // => true
  682. _.contains([1, 2, 3], 1, 2);
  683. // => false
  684. _.contains({ 'name': 'moe', 'age': 40 }, 'moe');
  685. // => true
  686. _.contains('curly', 'ur');
  687. // => true
  688. ```
  689. * * *
  690. <!-- /div -->
  691. <!-- div -->
  692. ### <a id="_countbycollection--callbackidentity-thisarg"></a>`_.countBy(collection [, callback=identity, thisArg])`
  693. <a href="#_countbycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2263 "View in source") [&#x24C9;][1]
  694. Creates an object composed of keys returned from running each element of the `collection` through the given `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)*.
  695. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  696. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  697. #### Arguments
  698. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  699. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  700. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  701. #### Returns
  702. *(Object)*: Returns the composed aggregate object.
  703. #### Example
  704. ```js
  705. _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
  706. // => { '4': 1, '6': 2 }
  707. _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
  708. // => { '4': 1, '6': 2 }
  709. _.countBy(['one', 'two', 'three'], 'length');
  710. // => { '3': 2, '5': 1 }
  711. ```
  712. * * *
  713. <!-- /div -->
  714. <!-- div -->
  715. ### <a id="_everycollection--callbackidentity-thisarg"></a>`_.every(collection [, callback=identity, thisArg])`
  716. <a href="#_everycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2315 "View in source") [&#x24C9;][1]
  717. Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
  718. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  719. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  720. #### Aliases
  721. *all*
  722. #### Arguments
  723. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  724. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  725. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  726. #### Returns
  727. *(Boolean)*: Returns `true` if all elements pass the callback check, else `false`.
  728. #### Example
  729. ```js
  730. _.every([true, 1, null, 'yes'], Boolean);
  731. // => false
  732. var stooges = [
  733. { 'name': 'moe', 'age': 40 },
  734. { 'name': 'larry', 'age': 50 }
  735. ];
  736. // using "_.pluck" callback shorthand
  737. _.every(stooges, 'age');
  738. // => true
  739. // using "_.where" callback shorthand
  740. _.every(stooges, { 'age': 50 });
  741. // => false
  742. ```
  743. * * *
  744. <!-- /div -->
  745. <!-- div -->
  746. ### <a id="_filtercollection--callbackidentity-thisarg"></a>`_.filter(collection [, callback=identity, thisArg])`
  747. <a href="#_filtercollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2376 "View in source") [&#x24C9;][1]
  748. Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
  749. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  750. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  751. #### Aliases
  752. *select*
  753. #### Arguments
  754. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  755. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  756. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  757. #### Returns
  758. *(Array)*: Returns a new array of elements that passed the callback check.
  759. #### Example
  760. ```js
  761. var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
  762. // => [2, 4, 6]
  763. var food = [
  764. { 'name': 'apple', 'organic': false, 'type': 'fruit' },
  765. { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
  766. ];
  767. // using "_.pluck" callback shorthand
  768. _.filter(food, 'organic');
  769. // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
  770. // using "_.where" callback shorthand
  771. _.filter(food, { 'type': 'fruit' });
  772. // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
  773. ```
  774. * * *
  775. <!-- /div -->
  776. <!-- div -->
  777. ### <a id="_findcollection--callbackidentity-thisarg"></a>`_.find(collection [, callback=identity, thisArg])`
  778. <a href="#_findcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2443 "View in source") [&#x24C9;][1]
  779. Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
  780. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  781. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  782. #### Aliases
  783. *detect*
  784. #### Arguments
  785. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  786. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  787. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  788. #### Returns
  789. *(Mixed)*: Returns the element that passed the callback check, else `undefined`.
  790. #### Example
  791. ```js
  792. var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
  793. // => 2
  794. var food = [
  795. { 'name': 'apple', 'organic': false, 'type': 'fruit' },
  796. { 'name': 'banana', 'organic': true, 'type': 'fruit' },
  797. { 'name': 'beet', 'organic': false, 'type': 'vegetable' },
  798. { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
  799. ];
  800. // using "_.where" callback shorthand
  801. var veggie = _.find(food, { 'type': 'vegetable' });
  802. // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
  803. // using "_.pluck" callback shorthand
  804. var healthy = _.find(food, 'organic');
  805. // => { 'name': 'banana', 'organic': true, 'type': 'fruit' }
  806. ```
  807. * * *
  808. <!-- /div -->
  809. <!-- div -->
  810. ### <a id="_foreachcollection--callbackidentity-thisarg"></a>`_.forEach(collection [, callback=identity, thisArg])`
  811. <a href="#_foreachcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2478 "View in source") [&#x24C9;][1]
  812. Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`.
  813. #### Aliases
  814. *each*
  815. #### Arguments
  816. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  817. 2. `[callback=identity]` *(Function)*: The function called per iteration.
  818. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  819. #### Returns
  820. *(Array, Object, String)*: Returns `collection`.
  821. #### Example
  822. ```js
  823. _([1, 2, 3]).forEach(alert).join(',');
  824. // => alerts each number and returns '1,2,3'
  825. _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
  826. // => alerts each number value (order is not guaranteed)
  827. ```
  828. * * *
  829. <!-- /div -->
  830. <!-- div -->
  831. ### <a id="_groupbycollection--callbackidentity-thisarg"></a>`_.groupBy(collection [, callback=identity, thisArg])`
  832. <a href="#_groupbycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [&#x24C9;][1]
  833. Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
  834. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  835. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`
  836. #### Arguments
  837. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  838. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  839. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  840. #### Returns
  841. *(Object)*: Returns the composed aggregate object.
  842. #### Example
  843. ```js
  844. _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
  845. // => { '4': [4.2], '6': [6.1, 6.4] }
  846. _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
  847. // => { '4': [4.2], '6': [6.1, 6.4] }
  848. // using "_.pluck" callback shorthand
  849. _.groupBy(['one', 'two', 'three'], 'length');
  850. // => { '3': ['one', 'two'], '5': ['three'] }
  851. ```
  852. * * *
  853. <!-- /div -->
  854. <!-- div -->
  855. ### <a id="_invokecollection-methodname--arg1-arg2-"></a>`_.invoke(collection, methodName [, arg1, arg2, ...])`
  856. <a href="#_invokecollection-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2561 "View in source") [&#x24C9;][1]
  857. 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 passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`.
  858. #### Arguments
  859. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  860. 2. `methodName` *(Function|String)*: The name of the method to invoke or the function invoked per iteration.
  861. 3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with.
  862. #### Returns
  863. *(Array)*: Returns a new array of the results of each invoked method.
  864. #### Example
  865. ```js
  866. _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
  867. // => [[1, 5, 7], [1, 2, 3]]
  868. _.invoke([123, 456], String.prototype.split, '');
  869. // => [['1', '2', '3'], ['4', '5', '6']]
  870. ```
  871. * * *
  872. <!-- /div -->
  873. <!-- div -->
  874. ### <a id="_mapcollection--callbackidentity-thisarg"></a>`_.map(collection [, callback=identity, thisArg])`
  875. <a href="#_mapcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2613 "View in source") [&#x24C9;][1]
  876. 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)*.
  877. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  878. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  879. #### Aliases
  880. *collect*
  881. #### Arguments
  882. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  883. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  884. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  885. #### Returns
  886. *(Array)*: Returns a new array of the results of each `callback` execution.
  887. #### Example
  888. ```js
  889. _.map([1, 2, 3], function(num) { return num * 3; });
  890. // => [3, 6, 9]
  891. _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
  892. // => [3, 6, 9] (order is not guaranteed)
  893. var stooges = [
  894. { 'name': 'moe', 'age': 40 },
  895. { 'name': 'larry', 'age': 50 }
  896. ];
  897. // using "_.pluck" callback shorthand
  898. _.map(stooges, 'name');
  899. // => ['moe', 'larry']
  900. ```
  901. * * *
  902. <!-- /div -->
  903. <!-- div -->
  904. ### <a id="_maxcollection--callbackidentity-thisarg"></a>`_.max(collection [, callback=identity, thisArg])`
  905. <a href="#_maxcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [&#x24C9;][1]
  906. Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
  907. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  908. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  909. #### Arguments
  910. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  911. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  912. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  913. #### Returns
  914. *(Mixed)*: Returns the maximum value.
  915. #### Example
  916. ```js
  917. _.max([4, 2, 8, 6]);
  918. // => 8
  919. var stooges = [
  920. { 'name': 'moe', 'age': 40 },
  921. { 'name': 'larry', 'age': 50 }
  922. ];
  923. _.max(stooges, function(stooge) { return stooge.age; });
  924. // => { 'name': 'larry', 'age': 50 };
  925. // using "_.pluck" callback shorthand
  926. _.max(stooges, 'age');
  927. // => { 'name': 'larry', 'age': 50 };
  928. ```
  929. * * *
  930. <!-- /div -->
  931. <!-- div -->
  932. ### <a id="_mincollection--callbackidentity-thisarg"></a>`_.min(collection [, callback=identity, thisArg])`
  933. <a href="#_mincollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2739 "View in source") [&#x24C9;][1]
  934. Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
  935. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  936. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  937. #### Arguments
  938. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  939. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  940. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  941. #### Returns
  942. *(Mixed)*: Returns the minimum value.
  943. #### Example
  944. ```js
  945. _.min([4, 2, 8, 6]);
  946. // => 2
  947. var stooges = [
  948. { 'name': 'moe', 'age': 40 },
  949. { 'name': 'larry', 'age': 50 }
  950. ];
  951. _.min(stooges, function(stooge) { return stooge.age; });
  952. // => { 'name': 'moe', 'age': 40 };
  953. // using "_.pluck" callback shorthand
  954. _.min(stooges, 'age');
  955. // => { 'name': 'moe', 'age': 40 };
  956. ```
  957. * * *
  958. <!-- /div -->
  959. <!-- div -->
  960. ### <a id="_pluckcollection-property"></a>`_.pluck(collection, property)`
  961. <a href="#_pluckcollection-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2789 "View in source") [&#x24C9;][1]
  962. Retrieves the value of a specified property from all elements in the `collection`.
  963. #### Arguments
  964. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  965. 2. `property` *(String)*: The property to pluck.
  966. #### Returns
  967. *(Array)*: Returns a new array of property values.
  968. #### Example
  969. ```js
  970. var stooges = [
  971. { 'name': 'moe', 'age': 40 },
  972. { 'name': 'larry', 'age': 50 }
  973. ];
  974. _.pluck(stooges, 'name');
  975. // => ['moe', 'larry']
  976. ```
  977. * * *
  978. <!-- /div -->
  979. <!-- div -->
  980. ### <a id="_reducecollection--callbackidentity-accumulator-thisarg"></a>`_.reduce(collection [, callback=identity, accumulator, thisArg])`
  981. <a href="#_reducecollection--callbackidentity-accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2821 "View in source") [&#x24C9;][1]
  982. Reduces a `collection` to a value that 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 passed, 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)*.
  983. #### Aliases
  984. *foldl, inject*
  985. #### Arguments
  986. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  987. 2. `[callback=identity]` *(Function)*: The function called per iteration.
  988. 3. `[accumulator]` *(Mixed)*: Initial value of the accumulator.
  989. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  990. #### Returns
  991. *(Mixed)*: Returns the accumulated value.
  992. #### Example
  993. ```js
  994. var sum = _.reduce([1, 2, 3], function(sum, num) {
  995. return sum + num;
  996. });
  997. // => 6
  998. var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
  999. result[key] = num * 3;
  1000. return result;
  1001. }, {});
  1002. // => { 'a': 3, 'b': 6, 'c': 9 }
  1003. ```
  1004. * * *
  1005. <!-- /div -->
  1006. <!-- div -->
  1007. ### <a id="_reducerightcollection--callbackidentity-accumulator-thisarg"></a>`_.reduceRight(collection [, callback=identity, accumulator, thisArg])`
  1008. <a href="#_reducerightcollection--callbackidentity-accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [&#x24C9;][1]
  1009. This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left.
  1010. #### Aliases
  1011. *foldr*
  1012. #### Arguments
  1013. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  1014. 2. `[callback=identity]` *(Function)*: The function called per iteration.
  1015. 3. `[accumulator]` *(Mixed)*: Initial value of the accumulator.
  1016. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1017. #### Returns
  1018. *(Mixed)*: Returns the accumulated value.
  1019. #### Example
  1020. ```js
  1021. var list = [[0, 1], [2, 3], [4, 5]];
  1022. var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
  1023. // => [4, 5, 2, 3, 0, 1]
  1024. ```
  1025. * * *
  1026. <!-- /div -->
  1027. <!-- div -->
  1028. ### <a id="_rejectcollection--callbackidentity-thisarg"></a>`_.reject(collection [, callback=identity, thisArg])`
  1029. <a href="#_rejectcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2924 "View in source") [&#x24C9;][1]
  1030. The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for.
  1031. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  1032. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  1033. #### Arguments
  1034. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  1035. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  1036. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1037. #### Returns
  1038. *(Array)*: Returns a new array of elements that did **not** pass the callback check.
  1039. #### Example
  1040. ```js
  1041. var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
  1042. // => [1, 3, 5]
  1043. var food = [
  1044. { 'name': 'apple', 'organic': false, 'type': 'fruit' },
  1045. { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
  1046. ];
  1047. // using "_.pluck" callback shorthand
  1048. _.reject(food, 'organic');
  1049. // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
  1050. // using "_.where" callback shorthand
  1051. _.reject(food, { 'type': 'fruit' });
  1052. // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
  1053. ```
  1054. * * *
  1055. <!-- /div -->
  1056. <!-- div -->
  1057. ### <a id="_shufflecollection"></a>`_.shuffle(collection)`
  1058. <a href="#_shufflecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2945 "View in source") [&#x24C9;][1]
  1059. Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
  1060. #### Arguments
  1061. 1. `collection` *(Array|Object|String)*: The collection to shuffle.
  1062. #### Returns
  1063. *(Array)*: Returns a new shuffled collection.
  1064. #### Example
  1065. ```js
  1066. _.shuffle([1, 2, 3, 4, 5, 6]);
  1067. // => [4, 1, 6, 3, 5, 2]
  1068. ```
  1069. * * *
  1070. <!-- /div -->
  1071. <!-- div -->
  1072. ### <a id="_sizecollection"></a>`_.size(collection)`
  1073. <a href="#_sizecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2978 "View in source") [&#x24C9;][1]
  1074. 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.
  1075. #### Arguments
  1076. 1. `collection` *(Array|Object|String)*: The collection to inspect.
  1077. #### Returns
  1078. *(Number)*: Returns `collection.length` or number of own enumerable properties.
  1079. #### Example
  1080. ```js
  1081. _.size([1, 2]);
  1082. // => 2
  1083. _.size({ 'one': 1, 'two': 2, 'three': 3 });
  1084. // => 3
  1085. _.size('curly');
  1086. // => 5
  1087. ```
  1088. * * *
  1089. <!-- /div -->
  1090. <!-- div -->
  1091. ### <a id="_somecollection--callbackidentity-thisarg"></a>`_.some(collection [, callback=identity, thisArg])`
  1092. <a href="#_somecollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3025 "View in source") [&#x24C9;][1]
  1093. Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds 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)*.
  1094. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  1095. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  1096. #### Aliases
  1097. *any*
  1098. #### Arguments
  1099. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  1100. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  1101. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1102. #### Returns
  1103. *(Boolean)*: Returns `true` if any element passes the callback check, else `false`.
  1104. #### Example
  1105. ```js
  1106. _.some([null, 0, 'yes', false], Boolean);
  1107. // => true
  1108. var food = [
  1109. { 'name': 'apple', 'organic': false, 'type': 'fruit' },
  1110. { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
  1111. ];
  1112. // using "_.pluck" callback shorthand
  1113. _.some(food, 'organic');
  1114. // => true
  1115. // using "_.where" callback shorthand
  1116. _.some(food, { 'type': 'meat' });
  1117. // => false
  1118. ```
  1119. * * *
  1120. <!-- /div -->
  1121. <!-- div -->
  1122. ### <a id="_sortbycollection--callbackidentity-thisarg"></a>`_.sortBy(collection [, callback=identity, thisArg])`
  1123. <a href="#_sortbycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [&#x24C9;][1]
  1124. Creates an array of elements, sorted in ascending order by the results of running each element in the `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)*.
  1125. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
  1126. If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`.
  1127. #### Arguments
  1128. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  1129. 2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
  1130. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1131. #### Returns
  1132. *(Array)*: Returns a new array of sorted elements.
  1133. #### Example
  1134. ```js
  1135. _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
  1136. // => [3, 1, 2]
  1137. _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
  1138. // => [3, 1, 2]
  1139. // using "_.pluck" callback shorthand
  1140. _.sortBy(['banana', 'strawberry', 'apple'], 'length');
  1141. // => ['apple', 'banana', 'strawberry']
  1142. ```
  1143. * * *
  1144. <!-- /div -->
  1145. <!-- div -->
  1146. ### <a id="_toarraycollection"></a>`_.toArray(collection)`
  1147. <a href="#_toarraycollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [&#x24C9;][1]
  1148. Converts the `collection` to an array.
  1149. #### Arguments
  1150. 1. `collection` *(Array|Object|String)*: The collection to convert.
  1151. #### Returns
  1152. *(Array)*: Returns the new converted array.
  1153. #### Example
  1154. ```js
  1155. (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
  1156. // => [2, 3, 4]
  1157. ```
  1158. * * *
  1159. <!-- /div -->
  1160. <!-- div -->
  1161. ### <a id="_wherecollection-properties"></a>`_.where(collection, properties)`
  1162. <a href="#_wherecollection-properties">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3148 "View in source") [&#x24C9;][1]
  1163. Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other.
  1164. #### Arguments
  1165. 1. `collection` *(Array|Object|String)*: The collection to iterate over.
  1166. 2. `properties` *(Object)*: The object of property values to filter by.
  1167. #### Returns
  1168. *(Array)*: Returns a new array of elements that have the given `properties`.
  1169. #### Example
  1170. ```js
  1171. var stooges = [
  1172. { 'name': 'moe', 'age': 40 },
  1173. { 'name': 'larry', 'age': 50 }
  1174. ];
  1175. _.where(stooges, { 'age': 40 });
  1176. // => [{ 'name': 'moe', 'age': 40 }]
  1177. ```
  1178. * * *
  1179. <!-- /div -->
  1180. <!-- /div -->
  1181. <!-- div -->
  1182. ## `Functions Methods`
  1183. <!-- div -->
  1184. ### <a id="_aftern-func"></a>`_.after(n, func)`
  1185. <a href="#_aftern-func">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4007 "View in source") [&#x24C9;][1]
  1186. Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function.
  1187. #### Arguments
  1188. 1. `n` *(Number)*: The number of times the function must be called before it is executed.
  1189. 2. `func` *(Function)*: The function to restrict.
  1190. #### Returns
  1191. *(Function)*: Returns the new restricted function.
  1192. #### Example
  1193. ```js
  1194. var renderNotes = _.after(notes.length, render);
  1195. _.forEach(notes, function(note) {
  1196. note.asyncSave({ 'success': renderNotes });
  1197. });
  1198. // `renderNotes` is run once, after all notes have saved
  1199. ```
  1200. * * *
  1201. <!-- /div -->
  1202. <!-- div -->
  1203. ### <a id="_bindfunc--thisarg-arg1-arg2-"></a>`_.bind(func [, thisArg, arg1, arg2, ...])`
  1204. <a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4040 "View in source") [&#x24C9;][1]
  1205. Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function.
  1206. #### Arguments
  1207. 1. `func` *(Function)*: The function to bind.
  1208. 2. `[thisArg]` *(Mixed)*: The `this` binding of `func`.
  1209. 3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied.
  1210. #### Returns
  1211. *(Function)*: Returns the new bound function.
  1212. #### Example
  1213. ```js
  1214. var func = function(greeting) {
  1215. return greeting + ' ' + this.name;
  1216. };
  1217. func = _.bind(func, { 'name': 'moe' }, 'hi');
  1218. func();
  1219. // => 'hi moe'
  1220. ```
  1221. * * *
  1222. <!-- /div -->
  1223. <!-- div -->
  1224. ### <a id="_bindallobject--methodname1-methodname2-"></a>`_.bindAll(object [, methodName1, methodName2, ...])`
  1225. <a href="#_bindallobject--methodname1-methodname2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4071 "View in source") [&#x24C9;][1]
  1226. Binds methods on `object` to `object`, 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.
  1227. #### Arguments
  1228. 1. `object` *(Object)*: The object to bind and assign the bound methods to.
  1229. 2. `[methodName1, methodName2, ...]` *(String)*: Method names on the object to bind.
  1230. #### Returns
  1231. *(Object)*: Returns `object`.
  1232. #### Example
  1233. ```js
  1234. var view = {
  1235. 'label': 'docs',
  1236. 'onClick': function() { alert('clicked ' + this.label); }
  1237. };
  1238. _.bindAll(view);
  1239. jQuery('#docs').on('click', view.onClick);
  1240. // => alerts 'clicked docs', when the button is clicked
  1241. ```
  1242. * * *
  1243. <!-- /div -->
  1244. <!-- div -->
  1245. ### <a id="_bindkeyobject-key--arg1-arg2-"></a>`_.bindKey(object, key [, arg1, arg2, ...])`
  1246. <a href="#_bindkeyobject-key--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4117 "View in source") [&#x24C9;][1]
  1247. Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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.
  1248. #### Arguments
  1249. 1. `object` *(Object)*: The object the method belongs to.
  1250. 2. `key` *(String)*: The key of the method.
  1251. 3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied.
  1252. #### Returns
  1253. *(Function)*: Returns the new bound function.
  1254. #### Example
  1255. ```js
  1256. var object = {
  1257. 'name': 'moe',
  1258. 'greet': function(greeting) {
  1259. return greeting + ' ' + this.name;
  1260. }
  1261. };
  1262. var func = _.bindKey(object, 'greet', 'hi');
  1263. func();
  1264. // => 'hi moe'
  1265. object.greet = function(greeting) {
  1266. return greeting + ', ' + this.name + '!';
  1267. };
  1268. func();
  1269. // => 'hi, moe!'
  1270. ```
  1271. * * *
  1272. <!-- /div -->
  1273. <!-- div -->
  1274. ### <a id="_composefunc1-func2-"></a>`_.compose([func1, func2, ...])`
  1275. <a href="#_composefunc1-func2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4140 "View in source") [&#x24C9;][1]
  1276. Creates a function that is the composition of the passed 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.
  1277. #### Arguments
  1278. 1. `[func1, func2, ...]` *(Function)*: Functions to compose.
  1279. #### Returns
  1280. *(Function)*: Returns the new composed function.
  1281. #### Example
  1282. ```js
  1283. var greet = function(name) { return 'hi ' + name; };
  1284. var exclaim = function(statement) { return statement + '!'; };
  1285. var welcome = _.compose(exclaim, greet);
  1286. welcome('moe');
  1287. // => 'hi moe!'
  1288. ```
  1289. * * *
  1290. <!-- /div -->
  1291. <!-- div -->
  1292. ### <a id="_debouncefunc-wait-immediate"></a>`_.debounce(func, wait, immediate)`
  1293. <a href="#_debouncefunc-wait-immediate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4173 "View in source") [&#x24C9;][1]
  1294. Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call.
  1295. #### Arguments
  1296. 1. `func` *(Function)*: The function to debounce.
  1297. 2. `wait` *(Number)*: The number of milliseconds to delay.
  1298. 3. `immediate` *(Boolean)*: A flag to indicate execution is on the leading edge of the timeout.
  1299. #### Returns
  1300. *(Function)*: Returns the new debounced function.
  1301. #### Example
  1302. ```js
  1303. var lazyLayout = _.debounce(calculateLayout, 300);
  1304. jQuery(window).on('resize', lazyLayout);
  1305. ```
  1306. * * *
  1307. <!-- /div -->
  1308. <!-- div -->
  1309. ### <a id="_deferfunc--arg1-arg2-"></a>`_.defer(func [, arg1, arg2, ...])`
  1310. <a href="#_deferfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4237 "View in source") [&#x24C9;][1]
  1311. Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked.
  1312. #### Arguments
  1313. 1. `func` *(Function)*: The function to defer.
  1314. 2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with.
  1315. #### Returns
  1316. *(Number)*: Returns the `setTimeout` timeout id.
  1317. #### Example
  1318. ```js
  1319. _.defer(function() { alert('deferred'); });
  1320. // returns from the function before `alert` is called
  1321. ```
  1322. * * *
  1323. <!-- /div -->
  1324. <!-- div -->
  1325. ### <a id="_delayfunc-wait--arg1-arg2-"></a>`_.delay(func, wait [, arg1, arg2, ...])`
  1326. <a href="#_delayfunc-wait--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [&#x24C9;][1]
  1327. Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked.
  1328. #### Arguments
  1329. 1. `func` *(Function)*: The function to delay.
  1330. 2. `wait` *(Number)*: The number of milliseconds to delay execution.
  1331. 3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with.
  1332. #### Returns
  1333. *(Number)*: Returns the `setTimeout` timeout id.
  1334. #### Example
  1335. ```js
  1336. var log = _.bind(console.log, console);
  1337. _.delay(log, 1000, 'logged later');
  1338. // => 'logged later' (Appears after one second.)
  1339. ```
  1340. * * *
  1341. <!-- /div -->
  1342. <!-- div -->
  1343. ### <a id="_memoizefunc--resolver"></a>`_.memoize(func [, resolver])`
  1344. <a href="#_memoizefunc--resolver">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4265 "View in source") [&#x24C9;][1]
  1345. Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function.
  1346. #### Arguments
  1347. 1. `func` *(Function)*: The function to have its output memoized.
  1348. 2. `[resolver]` *(Function)*: A function used to resolve the cache key.
  1349. #### Returns
  1350. *(Function)*: Returns the new memoizing function.
  1351. #### Example
  1352. ```js
  1353. var fibonacci = _.memoize(function(n) {
  1354. return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
  1355. });
  1356. ```
  1357. * * *
  1358. <!-- /div -->
  1359. <!-- div -->
  1360. ### <a id="_oncefunc"></a>`_.once(func)`
  1361. <a href="#_oncefunc">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4292 "View in source") [&#x24C9;][1]
  1362. 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.
  1363. #### Arguments
  1364. 1. `func` *(Function)*: The function to restrict.
  1365. #### Returns
  1366. *(Function)*: Returns the new restricted function.
  1367. #### Example
  1368. ```js
  1369. var initialize = _.once(createApplication);
  1370. initialize();
  1371. initialize();
  1372. // `initialize` executes `createApplication` once
  1373. ```
  1374. * * *
  1375. <!-- /div -->
  1376. <!-- div -->
  1377. ### <a id="_partialfunc--arg1-arg2-"></a>`_.partial(func [, arg1, arg2, ...])`
  1378. <a href="#_partialfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4327 "View in source") [&#x24C9;][1]
  1379. Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding.
  1380. #### Arguments
  1381. 1. `func` *(Function)*: The function to partially apply arguments to.
  1382. 2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied.
  1383. #### Returns
  1384. *(Function)*: Returns the new partially applied function.
  1385. #### Example
  1386. ```js
  1387. var greet = function(greeting, name) { return greeting + ' ' + name; };
  1388. var hi = _.partial(greet, 'hi');
  1389. hi('moe');
  1390. // => 'hi moe'
  1391. ```
  1392. * * *
  1393. <!-- /div -->
  1394. <!-- div -->
  1395. ### <a id="_partialrightfunc--arg1-arg2-"></a>`_.partialRight(func [, arg1, arg2, ...])`
  1396. <a href="#_partialrightfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4358 "View in source") [&#x24C9;][1]
  1397. This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function.
  1398. #### Arguments
  1399. 1. `func` *(Function)*: The function to partially apply arguments to.
  1400. 2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied.
  1401. #### Returns
  1402. *(Function)*: Returns the new partially applied function.
  1403. #### Example
  1404. ```js
  1405. var defaultsDeep = _.partialRight(_.merge, _.defaults);
  1406. var options = {
  1407. 'variable': 'data',
  1408. 'imports': { 'jq': $ }
  1409. };
  1410. defaultsDeep(options, _.templateSettings);
  1411. options.variable
  1412. // => 'data'
  1413. options.imports
  1414. // => { '_': _, 'jq': $ }
  1415. ```
  1416. * * *
  1417. <!-- /div -->
  1418. <!-- div -->
  1419. ### <a id="_throttlefunc-wait"></a>`_.throttle(func, wait)`
  1420. <a href="#_throttlefunc-wait">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4380 "View in source") [&#x24C9;][1]
  1421. Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call.
  1422. #### Arguments
  1423. 1. `func` *(Function)*: The function to throttle.
  1424. 2. `wait` *(Number)*: The number of milliseconds to throttle executions to.
  1425. #### Returns
  1426. *(Function)*: Returns the new throttled function.
  1427. #### Example
  1428. ```js
  1429. var throttled = _.throttle(updatePosition, 100);
  1430. jQuery(window).on('scroll', throttled);
  1431. ```
  1432. * * *
  1433. <!-- /div -->
  1434. <!-- div -->
  1435. ### <a id="_wrapvalue-wrapper"></a>`_.wrap(value, wrapper)`
  1436. <a href="#_wrapvalue-wrapper">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4433 "View in source") [&#x24C9;][1]
  1437. Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function.
  1438. #### Arguments
  1439. 1. `value` *(Mixed)*: The value to wrap.
  1440. 2. `wrapper` *(Function)*: The wrapper function.
  1441. #### Returns
  1442. *(Function)*: Returns the new function.
  1443. #### Example
  1444. ```js
  1445. var hello = function(name) { return 'hello ' + name; };
  1446. hello = _.wrap(hello, function(func) {
  1447. return 'before, ' + func('moe') + ', after';
  1448. });
  1449. hello();
  1450. // => 'before, hello moe, after'
  1451. ```
  1452. * * *
  1453. <!-- /div -->
  1454. <!-- /div -->
  1455. <!-- div -->
  1456. ## `Objects Methods`
  1457. <!-- div -->
  1458. ### <a id="_assignobject--source1-source2--callback-thisarg"></a>`_.assign(object [, source1, source2, ..., callback, thisArg])`
  1459. <a href="#_assignobject--source1-source2--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1062 "View in source") [&#x24C9;][1]
  1460. Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*.
  1461. #### Aliases
  1462. *extend*
  1463. #### Arguments
  1464. 1. `object` *(Object)*: The destination object.
  1465. 2. `[source1, source2, ...]` *(Object)*: The source objects.
  1466. 3. `[callback]` *(Function)*: The function to customize assigning values.
  1467. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1468. #### Returns
  1469. *(Object)*: Returns the destination object.
  1470. #### Example
  1471. ```js
  1472. _.assign({ 'name': 'moe' }, { 'age': 40 });
  1473. // => { 'name': 'moe', 'age': 40 }
  1474. var defaults = _.partialRight(_.assign, function(a, b) {
  1475. return typeof a == 'undefined' ? b : a;
  1476. });
  1477. var food = { 'name': 'apple' };
  1478. defaults(food, { 'name': 'banana', 'type': 'fruit' });
  1479. // => { 'name': 'apple', 'type': 'fruit' }
  1480. ```
  1481. * * *
  1482. <!-- /div -->
  1483. <!-- div -->
  1484. ### <a id="_clonevalue--deepfalse-callback-thisarg"></a>`_.clone(value [, deep=false, callback, thisArg])`
  1485. <a href="#_clonevalue--deepfalse-callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [&#x24C9;][1]
  1486. Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*.
  1487. #### Arguments
  1488. 1. `value` *(Mixed)*: The value to clone.
  1489. 2. `[deep=false]` *(Boolean)*: A flag to indicate a deep clone.
  1490. 3. `[callback]` *(Function)*: The function to customize cloning values.
  1491. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1492. #### Returns
  1493. *(Mixed)*: Returns the cloned `value`.
  1494. #### Example
  1495. ```js
  1496. var stooges = [
  1497. { 'name': 'moe', 'age': 40 },
  1498. { 'name': 'larry', 'age': 50 }
  1499. ];
  1500. var shallow = _.clone(stooges);
  1501. shallow[0] === stooges[0];
  1502. // => true
  1503. var deep = _.clone(stooges, true);
  1504. deep[0] === stooges[0];
  1505. // => false
  1506. _.mixin({
  1507. 'clone': _.partialRight(_.clone, function(value) {
  1508. return _.isElement(value) ? value.cloneNode(false) : undefined;
  1509. })
  1510. });
  1511. var clone = _.clone(document.body);
  1512. clone.childNodes.length;
  1513. // => 0
  1514. ```
  1515. * * *
  1516. <!-- /div -->
  1517. <!-- div -->
  1518. ### <a id="_clonedeepvalue--callback-thisarg"></a>`_.cloneDeep(value [, callback, thisArg])`
  1519. <a href="#_clonedeepvalue--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1242 "View in source") [&#x24C9;][1]
  1520. Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns the value it was passed, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*.
  1521. Note: This function is loosely based on the structured clone algorithm. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm.
  1522. #### Arguments
  1523. 1. `value` *(Mixed)*: The value to deep clone.
  1524. 2. `[callback]` *(Function)*: The function to customize cloning values.
  1525. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1526. #### Returns
  1527. *(Mixed)*: Returns the deep cloned `value`.
  1528. #### Example
  1529. ```js
  1530. var stooges = [
  1531. { 'name': 'moe', 'age': 40 },
  1532. { 'name': 'larry', 'age': 50 }
  1533. ];
  1534. var deep = _.cloneDeep(stooges);
  1535. deep[0] === stooges[0];
  1536. // => false
  1537. var view = {
  1538. 'label': 'docs',
  1539. 'node': element
  1540. };
  1541. var clone = _.cloneDeep(view, function(value) {
  1542. return _.isElement(value) ? value.cloneNode(true) : value;
  1543. });
  1544. clone.node == view.node;
  1545. // => false
  1546. ```
  1547. * * *
  1548. <!-- /div -->
  1549. <!-- div -->
  1550. ### <a id="_defaultsobject--source1-source2-"></a>`_.defaults(object [, source1, source2, ...])`
  1551. <a href="#_defaultsobject--source1-source2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [&#x24C9;][1]
  1552. Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored.
  1553. #### Arguments
  1554. 1. `object` *(Object)*: The destination object.
  1555. 2. `[source1, source2, ...]` *(Object)*: The source objects.
  1556. #### Returns
  1557. *(Object)*: Returns the destination object.
  1558. #### Example
  1559. ```js
  1560. var food = { 'name': 'apple' };
  1561. _.defaults(food, { 'name': 'banana', 'type': 'fruit' });
  1562. // => { 'name': 'apple', 'type': 'fruit' }
  1563. ```
  1564. * * *
  1565. <!-- /div -->
  1566. <!-- div -->
  1567. ### <a id="_forinobject--callbackidentity-thisarg"></a>`_.forIn(object [, callback=identity, thisArg])`
  1568. <a href="#_forinobject--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L882 "View in source") [&#x24C9;][1]
  1569. Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`.
  1570. #### Arguments
  1571. 1. `object` *(Object)*: The object to iterate over.
  1572. 2. `[callback=identity]` *(Function)*: The function called per iteration.
  1573. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1574. #### Returns
  1575. *(Object)*: Returns `object`.
  1576. #### Example
  1577. ```js
  1578. function Dog(name) {
  1579. this.name = name;
  1580. }
  1581. Dog.prototype.bark = function() {
  1582. alert('Woof, woof!');
  1583. };
  1584. _.forIn(new Dog('Dagny'), function(value, key) {
  1585. alert(key);
  1586. });
  1587. // => alerts 'name' and 'bark' (order is not guaranteed)
  1588. ```
  1589. * * *
  1590. <!-- /div -->
  1591. <!-- div -->
  1592. ### <a id="_forownobject--callbackidentity-thisarg"></a>`_.forOwn(object [, callback=identity, thisArg])`
  1593. <a href="#_forownobject--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L907 "View in source") [&#x24C9;][1]
  1594. Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`.
  1595. #### Arguments
  1596. 1. `object` *(Object)*: The object to iterate over.
  1597. 2. `[callback=identity]` *(Function)*: The function called per iteration.
  1598. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1599. #### Returns
  1600. *(Object)*: Returns `object`.
  1601. #### Example
  1602. ```js
  1603. _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
  1604. alert(key);
  1605. });
  1606. // => alerts '0', '1', and 'length' (order is not guaranteed)
  1607. ```
  1608. * * *
  1609. <!-- /div -->
  1610. <!-- div -->
  1611. ### <a id="_functionsobject"></a>`_.functions(object)`
  1612. <a href="#_functionsobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [&#x24C9;][1]
  1613. Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values.
  1614. #### Aliases
  1615. *methods*
  1616. #### Arguments
  1617. 1. `object` *(Object)*: The object to inspect.
  1618. #### Returns
  1619. *(Array)*: Returns a new array of property names that have function values.
  1620. #### Example
  1621. ```js
  1622. _.functions(_);
  1623. // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
  1624. ```
  1625. * * *
  1626. <!-- /div -->
  1627. <!-- div -->
  1628. ### <a id="_hasobject-property"></a>`_.has(object, property)`
  1629. <a href="#_hasobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [&#x24C9;][1]
  1630. Checks if the specified object `property` exists and is a direct property, instead of an inherited property.
  1631. #### Arguments
  1632. 1. `object` *(Object)*: The object to check.
  1633. 2. `property` *(String)*: The property to check for.
  1634. #### Returns
  1635. *(Boolean)*: Returns `true` if key is a direct property, else `false`.
  1636. #### Example
  1637. ```js
  1638. _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
  1639. // => true
  1640. ```
  1641. * * *
  1642. <!-- /div -->
  1643. <!-- div -->
  1644. ### <a id="_invertobject"></a>`_.invert(object)`
  1645. <a href="#_invertobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [&#x24C9;][1]
  1646. Creates an object composed of the inverted keys and values of the given `object`.
  1647. #### Arguments
  1648. 1. `object` *(Object)*: The object to invert.
  1649. #### Returns
  1650. *(Object)*: Returns the created inverted object.
  1651. #### Example
  1652. ```js
  1653. _.invert({ 'first': 'moe', 'second': 'larry' });
  1654. // => { 'moe': 'first', 'larry': 'second' } (order is not guaranteed)
  1655. ```
  1656. * * *
  1657. <!-- /div -->
  1658. <!-- div -->
  1659. ### <a id="_isargumentsvalue"></a>`_.isArguments(value)`
  1660. <a href="#_isargumentsvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L843 "View in source") [&#x24C9;][1]
  1661. Checks if `value` is an `arguments` object.
  1662. #### Arguments
  1663. 1. `value` *(Mixed)*: The value to check.
  1664. #### Returns
  1665. *(Boolean)*: Returns `true`, if the `value` is an `arguments` object, else `false`.
  1666. #### Example
  1667. ```js
  1668. (function() { return _.isArguments(arguments); })(1, 2, 3);
  1669. // => true
  1670. _.isArguments([1, 2, 3]);
  1671. // => false
  1672. ```
  1673. * * *
  1674. <!-- /div -->
  1675. <!-- div -->
  1676. ### <a id="_isarrayvalue"></a>`_.isArray(value)`
  1677. <a href="#_isarrayvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L925 "View in source") [&#x24C9;][1]
  1678. Checks if `value` is an array.
  1679. #### Arguments
  1680. 1. `value` *(Mixed)*: The value to check.
  1681. #### Returns
  1682. *(Boolean)*: Returns `true`, if the `value` is an array, else `false`.
  1683. #### Example
  1684. ```js
  1685. (function() { return _.isArray(arguments); })();
  1686. // => false
  1687. _.isArray([1, 2, 3]);
  1688. // => true
  1689. ```
  1690. * * *
  1691. <!-- /div -->
  1692. <!-- div -->
  1693. ### <a id="_isbooleanvalue"></a>`_.isBoolean(value)`
  1694. <a href="#_isbooleanvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351 "View in source") [&#x24C9;][1]
  1695. Checks if `value` is a boolean value.
  1696. #### Arguments
  1697. 1. `value` *(Mixed)*: The value to check.
  1698. #### Returns
  1699. *(Boolean)*: Returns `true`, if the `value` is a boolean value, else `false`.
  1700. #### Example
  1701. ```js
  1702. _.isBoolean(null);
  1703. // => false
  1704. ```
  1705. * * *
  1706. <!-- /div -->
  1707. <!-- div -->
  1708. ### <a id="_isdatevalue"></a>`_.isDate(value)`
  1709. <a href="#_isdatevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1368 "View in source") [&#x24C9;][1]
  1710. Checks if `value` is a date.
  1711. #### Arguments
  1712. 1. `value` *(Mixed)*: The value to check.
  1713. #### Returns
  1714. *(Boolean)*: Returns `true`, if the `value` is a date, else `false`.
  1715. #### Example
  1716. ```js
  1717. _.isDate(new Date);
  1718. // => true
  1719. ```
  1720. * * *
  1721. <!-- /div -->
  1722. <!-- div -->
  1723. ### <a id="_iselementvalue"></a>`_.isElement(value)`
  1724. <a href="#_iselementvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1385 "View in source") [&#x24C9;][1]
  1725. Checks if `value` is a DOM element.
  1726. #### Arguments
  1727. 1. `value` *(Mixed)*: The value to check.
  1728. #### Returns
  1729. *(Boolean)*: Returns `true`, if the `value` is a DOM element, else `false`.
  1730. #### Example
  1731. ```js
  1732. _.isElement(document.body);
  1733. // => true
  1734. ```
  1735. * * *
  1736. <!-- /div -->
  1737. <!-- div -->
  1738. ### <a id="_isemptyvalue"></a>`_.isEmpty(value)`
  1739. <a href="#_isemptyvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1410 "View in source") [&#x24C9;][1]
  1740. Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty".
  1741. #### Arguments
  1742. 1. `value` *(Array|Object|String)*: The value to inspect.
  1743. #### Returns
  1744. *(Boolean)*: Returns `true`, if the `value` is empty, else `false`.
  1745. #### Example
  1746. ```js
  1747. _.isEmpty([1, 2, 3]);
  1748. // => false
  1749. _.isEmpty({});
  1750. // => true
  1751. _.isEmpty('');
  1752. // => true
  1753. ```
  1754. * * *
  1755. <!-- /div -->
  1756. <!-- div -->
  1757. ### <a id="_isequala-b--callback-thisarg"></a>`_.isEqual(a, b [, callback, thisArg])`
  1758. <a href="#_isequala-b--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1469 "View in source") [&#x24C9;][1]
  1759. Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*.
  1760. #### Arguments
  1761. 1. `a` *(Mixed)*: The value to compare.
  1762. 2. `b` *(Mixed)*: The other value to compare.
  1763. 3. `[callback]` *(Function)*: The function to customize comparing values.
  1764. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1765. #### Returns
  1766. *(Boolean)*: Returns `true`, if the values are equvalent, else `false`.
  1767. #### Example
  1768. ```js
  1769. var moe = { 'name': 'moe', 'age': 40 };
  1770. var copy = { 'name': 'moe', 'age': 40 };
  1771. moe == copy;
  1772. // => false
  1773. _.isEqual(moe, copy);
  1774. // => true
  1775. var words = ['hello', 'goodbye'];
  1776. var otherWords = ['hi', 'goodbye'];
  1777. _.isEqual(words, otherWords, function(a, b) {
  1778. var reGreet = /^(?:hello|hi)$/i,
  1779. aGreet = _.isString(a) && reGreet.test(a),
  1780. bGreet = _.isString(b) && reGreet.test(b);
  1781. return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
  1782. });
  1783. // => true
  1784. ```
  1785. * * *
  1786. <!-- /div -->
  1787. <!-- div -->
  1788. ### <a id="_isfinitevalue"></a>`_.isFinite(value)`
  1789. <a href="#_isfinitevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1650 "View in source") [&#x24C9;][1]
  1790. Checks if `value` is, or can be coerced to, a finite number.
  1791. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5.
  1792. #### Arguments
  1793. 1. `value` *(Mixed)*: The value to check.
  1794. #### Returns
  1795. *(Boolean)*: Returns `true`, if the `value` is finite, else `false`.
  1796. #### Example
  1797. ```js
  1798. _.isFinite(-101);
  1799. // => true
  1800. _.isFinite('10');
  1801. // => true
  1802. _.isFinite(true);
  1803. // => false
  1804. _.isFinite('');
  1805. // => false
  1806. _.isFinite(Infinity);
  1807. // => false
  1808. ```
  1809. * * *
  1810. <!-- /div -->
  1811. <!-- div -->
  1812. ### <a id="_isfunctionvalue"></a>`_.isFunction(value)`
  1813. <a href="#_isfunctionvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1667 "View in source") [&#x24C9;][1]
  1814. Checks if `value` is a function.
  1815. #### Arguments
  1816. 1. `value` *(Mixed)*: The value to check.
  1817. #### Returns
  1818. *(Boolean)*: Returns `true`, if the `value` is a function, else `false`.
  1819. #### Example
  1820. ```js
  1821. _.isFunction(_);
  1822. // => true
  1823. ```
  1824. * * *
  1825. <!-- /div -->
  1826. <!-- div -->
  1827. ### <a id="_isnanvalue"></a>`_.isNaN(value)`
  1828. <a href="#_isnanvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1730 "View in source") [&#x24C9;][1]
  1829. Checks if `value` is `NaN`.
  1830. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
  1831. #### Arguments
  1832. 1. `value` *(Mixed)*: The value to check.
  1833. #### Returns
  1834. *(Boolean)*: Returns `true`, if the `value` is `NaN`, else `false`.
  1835. #### Example
  1836. ```js
  1837. _.isNaN(NaN);
  1838. // => true
  1839. _.isNaN(new Number(NaN));
  1840. // => true
  1841. isNaN(undefined);
  1842. // => true
  1843. _.isNaN(undefined);
  1844. // => false
  1845. ```
  1846. * * *
  1847. <!-- /div -->
  1848. <!-- div -->
  1849. ### <a id="_isnullvalue"></a>`_.isNull(value)`
  1850. <a href="#_isnullvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1752 "View in source") [&#x24C9;][1]
  1851. Checks if `value` is `null`.
  1852. #### Arguments
  1853. 1. `value` *(Mixed)*: The value to check.
  1854. #### Returns
  1855. *(Boolean)*: Returns `true`, if the `value` is `null`, else `false`.
  1856. #### Example
  1857. ```js
  1858. _.isNull(null);
  1859. // => true
  1860. _.isNull(undefined);
  1861. // => false
  1862. ```
  1863. * * *
  1864. <!-- /div -->
  1865. <!-- div -->
  1866. ### <a id="_isnumbervalue"></a>`_.isNumber(value)`
  1867. <a href="#_isnumbervalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1769 "View in source") [&#x24C9;][1]
  1868. Checks if `value` is a number.
  1869. #### Arguments
  1870. 1. `value` *(Mixed)*: The value to check.
  1871. #### Returns
  1872. *(Boolean)*: Returns `true`, if the `value` is a number, else `false`.
  1873. #### Example
  1874. ```js
  1875. _.isNumber(8.4 * 5);
  1876. // => true
  1877. ```
  1878. * * *
  1879. <!-- /div -->
  1880. <!-- div -->
  1881. ### <a id="_isobjectvalue"></a>`_.isObject(value)`
  1882. <a href="#_isobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1697 "View in source") [&#x24C9;][1]
  1883. Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)*
  1884. #### Arguments
  1885. 1. `value` *(Mixed)*: The value to check.
  1886. #### Returns
  1887. *(Boolean)*: Returns `true`, if the `value` is an object, else `false`.
  1888. #### Example
  1889. ```js
  1890. _.isObject({});
  1891. // => true
  1892. _.isObject([1, 2, 3]);
  1893. // => true
  1894. _.isObject(1);
  1895. // => false
  1896. ```
  1897. * * *
  1898. <!-- /div -->
  1899. <!-- div -->
  1900. ### <a id="_isplainobjectvalue"></a>`_.isPlainObject(value)`
  1901. <a href="#_isplainobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1797 "View in source") [&#x24C9;][1]
  1902. Checks if a given `value` is an object created by the `Object` constructor.
  1903. #### Arguments
  1904. 1. `value` *(Mixed)*: The value to check.
  1905. #### Returns
  1906. *(Boolean)*: Returns `true`, if `value` is a plain object, else `false`.
  1907. #### Example
  1908. ```js
  1909. function Stooge(name, age) {
  1910. this.name = name;
  1911. this.age = age;
  1912. }
  1913. _.isPlainObject(new Stooge('moe', 40));
  1914. // => false
  1915. _.isPlainObject([1, 2, 3]);
  1916. // => false
  1917. _.isPlainObject({ 'name': 'moe', 'age': 40 });
  1918. // => true
  1919. ```
  1920. * * *
  1921. <!-- /div -->
  1922. <!-- div -->
  1923. ### <a id="_isregexpvalue"></a>`_.isRegExp(value)`
  1924. <a href="#_isregexpvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1822 "View in source") [&#x24C9;][1]
  1925. Checks if `value` is a regular expression.
  1926. #### Arguments
  1927. 1. `value` *(Mixed)*: The value to check.
  1928. #### Returns
  1929. *(Boolean)*: Returns `true`, if the `value` is a regular expression, else `false`.
  1930. #### Example
  1931. ```js
  1932. _.isRegExp(/moe/);
  1933. // => true
  1934. ```
  1935. * * *
  1936. <!-- /div -->
  1937. <!-- div -->
  1938. ### <a id="_isstringvalue"></a>`_.isString(value)`
  1939. <a href="#_isstringvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1839 "View in source") [&#x24C9;][1]
  1940. Checks if `value` is a string.
  1941. #### Arguments
  1942. 1. `value` *(Mixed)*: The value to check.
  1943. #### Returns
  1944. *(Boolean)*: Returns `true`, if the `value` is a string, else `false`.
  1945. #### Example
  1946. ```js
  1947. _.isString('moe');
  1948. // => true
  1949. ```
  1950. * * *
  1951. <!-- /div -->
  1952. <!-- div -->
  1953. ### <a id="_isundefinedvalue"></a>`_.isUndefined(value)`
  1954. <a href="#_isundefinedvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1856 "View in source") [&#x24C9;][1]
  1955. Checks if `value` is `undefined`.
  1956. #### Arguments
  1957. 1. `value` *(Mixed)*: The value to check.
  1958. #### Returns
  1959. *(Boolean)*: Returns `true`, if the `value` is `undefined`, else `false`.
  1960. #### Example
  1961. ```js
  1962. _.isUndefined(void 0);
  1963. // => true
  1964. ```
  1965. * * *
  1966. <!-- /div -->
  1967. <!-- div -->
  1968. ### <a id="_keysobject"></a>`_.keys(object)`
  1969. <a href="#_keysobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L944 "View in source") [&#x24C9;][1]
  1970. Creates an array composed of the own enumerable property names of `object`.
  1971. #### Arguments
  1972. 1. `object` *(Object)*: The object to inspect.
  1973. #### Returns
  1974. *(Array)*: Returns a new array of property names.
  1975. #### Example
  1976. ```js
  1977. _.keys({ 'one': 1, 'two': 2, 'three': 3 });
  1978. // => ['one', 'two', 'three'] (order is not guaranteed)
  1979. ```
  1980. * * *
  1981. <!-- /div -->
  1982. <!-- div -->
  1983. ### <a id="_mergeobject--source1-source2--callback-thisarg"></a>`_.merge(object [, source1, source2, ..., callback, thisArg])`
  1984. <a href="#_mergeobject--source1-source2--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [&#x24C9;][1]
  1985. Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*.
  1986. #### Arguments
  1987. 1. `object` *(Object)*: The destination object.
  1988. 2. `[source1, source2, ...]` *(Object)*: The source objects.
  1989. 3. `[callback]` *(Function)*: The function to customize merging properties.
  1990. 4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  1991. #### Returns
  1992. *(Object)*: Returns the destination object.
  1993. #### Example
  1994. ```js
  1995. var names = {
  1996. 'stooges': [
  1997. { 'name': 'moe' },
  1998. { 'name': 'larry' }
  1999. ]
  2000. };
  2001. var ages = {
  2002. 'stooges': [
  2003. { 'age': 40 },
  2004. { 'age': 50 }
  2005. ]
  2006. };
  2007. _.merge(names, ages);
  2008. // => { 'stooges': [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] }
  2009. var food = {
  2010. 'fruits': ['apple'],
  2011. 'vegetables': ['beet']
  2012. };
  2013. var otherFood = {
  2014. 'fruits': ['banana'],
  2015. 'vegetables': ['carrot']
  2016. };
  2017. _.merge(food, otherFood, function(a, b) {
  2018. return _.isArray(a) ? a.concat(b) : undefined;
  2019. });
  2020. // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] }
  2021. ```
  2022. * * *
  2023. <!-- /div -->
  2024. <!-- div -->
  2025. ### <a id="_omitobject-callback-prop1-prop2--thisarg"></a>`_.omit(object, callback|[prop1, prop2, ..., thisArg])`
  2026. <a href="#_omitobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2023 "View in source") [&#x24C9;][1]
  2027. Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
  2028. #### Arguments
  2029. 1. `object` *(Object)*: The source object.
  2030. 2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to omit or the function called per iteration.
  2031. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  2032. #### Returns
  2033. *(Object)*: Returns an object without the omitted properties.
  2034. #### Example
  2035. ```js
  2036. _.omit({ 'name': 'moe', 'age': 40 }, 'age');
  2037. // => { 'name': 'moe' }
  2038. _.omit({ 'name': 'moe', 'age': 40 }, function(value) {
  2039. return typeof value == 'number';
  2040. });
  2041. // => { 'name': 'moe' }
  2042. ```
  2043. * * *
  2044. <!-- /div -->
  2045. <!-- div -->
  2046. ### <a id="_pairsobject"></a>`_.pairs(object)`
  2047. <a href="#_pairsobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2057 "View in source") [&#x24C9;][1]
  2048. Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`.
  2049. #### Arguments
  2050. 1. `object` *(Object)*: The object to inspect.
  2051. #### Returns
  2052. *(Array)*: Returns new array of key-value pairs.
  2053. #### Example
  2054. ```js
  2055. _.pairs({ 'moe': 30, 'larry': 40 });
  2056. // => [['moe', 30], ['larry', 40]] (order is not guaranteed)
  2057. ```
  2058. * * *
  2059. <!-- /div -->
  2060. <!-- div -->
  2061. ### <a id="_pickobject-callback-prop1-prop2--thisarg"></a>`_.pick(object, callback|[prop1, prop2, ..., thisArg])`
  2062. <a href="#_pickobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2095 "View in source") [&#x24C9;][1]
  2063. Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
  2064. #### Arguments
  2065. 1. `object` *(Object)*: The source object.
  2066. 2. `callback|[prop1, prop2, ...]` *(Array|Function|String)*: The function called per iteration or properties to pick, either as individual arguments or arrays.
  2067. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  2068. #### Returns
  2069. *(Object)*: Returns an object composed of the picked properties.
  2070. #### Example
  2071. ```js
  2072. _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name');
  2073. // => { 'name': 'moe' }
  2074. _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) {
  2075. return key.charAt(0) != '_';
  2076. });
  2077. // => { 'name': 'moe' }
  2078. ```
  2079. * * *
  2080. <!-- /div -->
  2081. <!-- div -->
  2082. ### <a id="_valuesobject"></a>`_.values(object)`
  2083. <a href="#_valuesobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2132 "View in source") [&#x24C9;][1]
  2084. Creates an array composed of the own enumerable property values of `object`.
  2085. #### Arguments
  2086. 1. `object` *(Object)*: The object to inspect.
  2087. #### Returns
  2088. *(Array)*: Returns a new array of property values.
  2089. #### Example
  2090. ```js
  2091. _.values({ 'one': 1, 'two': 2, 'three': 3 });
  2092. // => [1, 2, 3]
  2093. ```
  2094. * * *
  2095. <!-- /div -->
  2096. <!-- /div -->
  2097. <!-- div -->
  2098. ## `Utilities Methods`
  2099. <!-- div -->
  2100. ### <a id="_escapestring"></a>`_.escape(string)`
  2101. <a href="#_escapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4457 "View in source") [&#x24C9;][1]
  2102. Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities.
  2103. #### Arguments
  2104. 1. `string` *(String)*: The string to escape.
  2105. #### Returns
  2106. *(String)*: Returns the escaped string.
  2107. #### Example
  2108. ```js
  2109. _.escape('Moe, Larry & Curly');
  2110. // => 'Moe, Larry &amp; Curly'
  2111. ```
  2112. * * *
  2113. <!-- /div -->
  2114. <!-- div -->
  2115. ### <a id="_identityvalue"></a>`_.identity(value)`
  2116. <a href="#_identityvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4475 "View in source") [&#x24C9;][1]
  2117. This function returns the first argument passed to it.
  2118. #### Arguments
  2119. 1. `value` *(Mixed)*: Any value.
  2120. #### Returns
  2121. *(Mixed)*: Returns `value`.
  2122. #### Example
  2123. ```js
  2124. var moe = { 'name': 'moe' };
  2125. moe === _.identity(moe);
  2126. // => true
  2127. ```
  2128. * * *
  2129. <!-- /div -->
  2130. <!-- div -->
  2131. ### <a id="_mixinobject"></a>`_.mixin(object)`
  2132. <a href="#_mixinobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4501 "View in source") [&#x24C9;][1]
  2133. Adds functions properties of `object` to the `lodash` function and chainable wrapper.
  2134. #### Arguments
  2135. 1. `object` *(Object)*: The object of function properties to add to `lodash`.
  2136. #### Example
  2137. ```js
  2138. _.mixin({
  2139. 'capitalize': function(string) {
  2140. return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
  2141. }
  2142. });
  2143. _.capitalize('moe');
  2144. // => 'Moe'
  2145. _('moe').capitalize();
  2146. // => 'Moe'
  2147. ```
  2148. * * *
  2149. <!-- /div -->
  2150. <!-- div -->
  2151. ### <a id="_noconflict"></a>`_.noConflict()`
  2152. <a href="#_noconflict">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4525 "View in source") [&#x24C9;][1]
  2153. Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
  2154. #### Returns
  2155. *(Function)*: Returns the `lodash` function.
  2156. #### Example
  2157. ```js
  2158. var lodash = _.noConflict();
  2159. ```
  2160. * * *
  2161. <!-- /div -->
  2162. <!-- div -->
  2163. ### <a id="_randommin0-max1"></a>`_.random([min=0, max=1])`
  2164. <a href="#_randommin0-max1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4548 "View in source") [&#x24C9;][1]
  2165. Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned.
  2166. #### Arguments
  2167. 1. `[min=0]` *(Number)*: The minimum possible value.
  2168. 2. `[max=1]` *(Number)*: The maximum possible value.
  2169. #### Returns
  2170. *(Number)*: Returns a random number.
  2171. #### Example
  2172. ```js
  2173. _.random(0, 5);
  2174. // => a number between 0 and 5
  2175. _.random(5);
  2176. // => also a number between 0 and 5
  2177. ```
  2178. * * *
  2179. <!-- /div -->
  2180. <!-- div -->
  2181. ### <a id="_resultobject-property"></a>`_.result(object, property)`
  2182. <a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4586 "View in source") [&#x24C9;][1]
  2183. Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned.
  2184. #### Arguments
  2185. 1. `object` *(Object)*: The object to inspect.
  2186. 2. `property` *(String)*: The property to get the value of.
  2187. #### Returns
  2188. *(Mixed)*: Returns the resolved value.
  2189. #### Example
  2190. ```js
  2191. var object = {
  2192. 'cheese': 'crumpets',
  2193. 'stuff': function() {
  2194. return 'nonsense';
  2195. }
  2196. };
  2197. _.result(object, 'cheese');
  2198. // => 'crumpets'
  2199. _.result(object, 'stuff');
  2200. // => 'nonsense'
  2201. ```
  2202. * * *
  2203. <!-- /div -->
  2204. <!-- div -->
  2205. ### <a id="_templatetext-data-options"></a>`_.template(text, data, options)`
  2206. <a href="#_templatetext-data-options">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4674 "View in source") [&#x24C9;][1]
  2207. A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
  2208. Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
  2209. Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and using precompiled templates, or loading Lo-Dash in a sandbox.
  2210. For more information on precompiling templates see:<br>
  2211. http://lodash.com/#custom-builds
  2212. For more information on Chrome extension sandboxes see:<br>
  2213. http://developer.chrome.com/stable/extensions/sandboxingEval.html
  2214. #### Arguments
  2215. 1. `text` *(String)*: The template text.
  2216. 2. `data` *(Obect)*: The data object used to populate the text.
  2217. 3. `options` *(Object)*: The options object. escape - The "escape" delimiter regexp. evaluate - The "evaluate" delimiter regexp. interpolate - The "interpolate" delimiter regexp. sourceURL - The sourceURL of the template's compiled source. variable - The data object variable name.
  2218. #### Returns
  2219. *(Function, String)*: Returns a compiled function when no `data` object is given, else it returns the interpolated text.
  2220. #### Example
  2221. ```js
  2222. // using a compiled template
  2223. var compiled = _.template('hello <%= name %>');
  2224. compiled({ 'name': 'moe' });
  2225. // => 'hello moe'
  2226. var list = '<% _.forEach(people, function(name) { %><li><%= name %></li><% }); %>';
  2227. _.template(list, { 'people': ['moe', 'larry'] });
  2228. // => '<li>moe</li><li>larry</li>'
  2229. // using the "escape" delimiter to escape HTML in data property values
  2230. _.template('<b><%- value %></b>', { 'value': '<script>' });
  2231. // => '<b>&lt;script&gt;</b>'
  2232. // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
  2233. _.template('hello ${ name }', { 'name': 'curly' });
  2234. // => 'hello curly'
  2235. // using the internal `print` function in "evaluate" delimiters
  2236. _.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' });
  2237. // => 'hello stooge!'
  2238. // using custom template delimiters
  2239. _.templateSettings = {
  2240. 'interpolate': /{{([\s\S]+?)}}/g
  2241. };
  2242. _.template('hello {{ name }}!', { 'name': 'mustache' });
  2243. // => 'hello mustache!'
  2244. // using the `sourceURL` option to specify a custom sourceURL for the template
  2245. var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
  2246. compiled(data);
  2247. // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
  2248. // using the `variable` option to ensure a with-statement isn't used in the compiled template
  2249. var compiled = _.template('hi <%= data.name %>!', null, { 'variable': 'data' });
  2250. compiled.source;
  2251. // => function(data) {
  2252. var __t, __p = '', __e = _.escape;
  2253. __p += 'hi ' + ((__t = ( data.name )) == null ? '' : __t) + '!';
  2254. return __p;
  2255. }
  2256. // using the `source` property to inline compiled templates for meaningful
  2257. // line numbers in error messages and a stack trace
  2258. fs.writeFileSync(path.join(cwd, 'jst.js'), '\
  2259. var JST = {\
  2260. "main": ' + _.template(mainText).source + '\
  2261. };\
  2262. ');
  2263. ```
  2264. * * *
  2265. <!-- /div -->
  2266. <!-- div -->
  2267. ### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback [, thisArg])`
  2268. <a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4800 "View in source") [&#x24C9;][1]
  2269. Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*.
  2270. #### Arguments
  2271. 1. `n` *(Number)*: The number of times to execute the callback.
  2272. 2. `callback` *(Function)*: The function called per iteration.
  2273. 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
  2274. #### Returns
  2275. *(Array)*: Returns a new array of the results of each `callback` execution.
  2276. #### Example
  2277. ```js
  2278. var diceRolls = _.times(3, _.partial(_.random, 1, 6));
  2279. // => [3, 6, 4]
  2280. _.times(3, function(n) { mage.castSpell(n); });
  2281. // => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
  2282. _.times(3, function(n) { this.cast(n); }, mage);
  2283. // => also calls `mage.castSpell(n)` three times
  2284. ```
  2285. * * *
  2286. <!-- /div -->
  2287. <!-- div -->
  2288. ### <a id="_unescapestring"></a>`_.unescape(string)`
  2289. <a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4826 "View in source") [&#x24C9;][1]
  2290. The opposite of `_.escape`, this method converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to their corresponding characters.
  2291. #### Arguments
  2292. 1. `string` *(String)*: The string to unescape.
  2293. #### Returns
  2294. *(String)*: Returns the unescaped string.
  2295. #### Example
  2296. ```js
  2297. _.unescape('Moe, Larry &amp; Curly');
  2298. // => 'Moe, Larry & Curly'
  2299. ```
  2300. * * *
  2301. <!-- /div -->
  2302. <!-- div -->
  2303. ### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])`
  2304. <a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4846 "View in source") [&#x24C9;][1]
  2305. Generates a unique ID. If `prefix` is passed, the ID will be appended to it.
  2306. #### Arguments
  2307. 1. `[prefix]` *(String)*: The value to prefix the ID with.
  2308. #### Returns
  2309. *(String)*: Returns the unique ID.
  2310. #### Example
  2311. ```js
  2312. _.uniqueId('contact_');
  2313. // => 'contact_104'
  2314. _.uniqueId();
  2315. // => '105'
  2316. ```
  2317. * * *
  2318. <!-- /div -->
  2319. <!-- /div -->
  2320. <!-- div -->
  2321. ## `Methods`
  2322. <!-- div -->
  2323. ### <a id="_templatesettingsimports_"></a>`_.templateSettings.imports._`
  2324. <a href="#_templatesettingsimports_">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L341 "View in source") [&#x24C9;][1]
  2325. A reference to the `lodash` function.
  2326. * * *
  2327. <!-- /div -->
  2328. <!-- /div -->
  2329. <!-- div -->
  2330. ## `Properties`
  2331. <!-- div -->
  2332. ### <a id="_version"></a>`_.VERSION`
  2333. <a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5076 "View in source") [&#x24C9;][1]
  2334. *(String)*: The semantic version number.
  2335. * * *
  2336. <!-- /div -->
  2337. <!-- div -->
  2338. ### <a id="_templatesettings"></a>`_.templateSettings`
  2339. <a href="#_templatesettings">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L293 "View in source") [&#x24C9;][1]
  2340. *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters.
  2341. * * *
  2342. <!-- /div -->
  2343. <!-- div -->
  2344. ### <a id="_templatesettingsescape"></a>`_.templateSettings.escape`
  2345. <a href="#_templatesettingsescape">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L301 "View in source") [&#x24C9;][1]
  2346. *(RegExp)*: Used to detect `data` property values to be HTML-escaped.
  2347. * * *
  2348. <!-- /div -->
  2349. <!-- div -->
  2350. ### <a id="_templatesettingsevaluate"></a>`_.templateSettings.evaluate`
  2351. <a href="#_templatesettingsevaluate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L309 "View in source") [&#x24C9;][1]
  2352. *(RegExp)*: Used to detect code to be evaluated.
  2353. * * *
  2354. <!-- /div -->
  2355. <!-- div -->
  2356. ### <a id="_templatesettingsinterpolate"></a>`_.templateSettings.interpolate`
  2357. <a href="#_templatesettingsinterpolate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L317 "View in source") [&#x24C9;][1]
  2358. *(RegExp)*: Used to detect `data` property values to inject.
  2359. * * *
  2360. <!-- /div -->
  2361. <!-- div -->
  2362. ### <a id="_templatesettingsvariable"></a>`_.templateSettings.variable`
  2363. <a href="#_templatesettingsvariable">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L325 "View in source") [&#x24C9;][1]
  2364. *(String)*: Used to reference the data object in the template text.
  2365. * * *
  2366. <!-- /div -->
  2367. <!-- div -->
  2368. ### <a id="_templatesettingsimports"></a>`_.templateSettings.imports`
  2369. <a href="#_templatesettingsimports">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L333 "View in source") [&#x24C9;][1]
  2370. *(Object)*: Used to import variables into the compiled template.
  2371. * * *
  2372. <!-- /div -->
  2373. <!-- /div -->
  2374. <!-- /div -->
  2375. [1]: #Arrays "Jump back to the TOC."