Debian Codegraph @

index.html

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
5 <meta http-equiv="X-UA-Compatible" content="chrome=1" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7
8 <link rel="canonical" href="https://underscorejs.org/" />
9 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
10 <title>Underscore.js</title>
11 <style>
12 body {
13 font-size: 14px;
14 line-height: 22px;
15 background: #f4f4f4 url(docs/images/background.png);
16 color: #000;
17 font-family: Helvetica Neue, Helvetica, Arial;
18 }
19 .interface {
20 font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif !important;
21 }
22 .container{
23 margin-top:50px;
24 }
25 div#sidebar {
26 background: #fff;
27 position: fixed;
28 top: 0; left: 0; bottom: 0;
29 width: 220px;
30 overflow-y: auto;
31 overflow-x: hidden;
32 -webkit-overflow-scrolling: touch;
33 padding: 15px 0 30px 30px;
34 border-right: 1px solid #bbb;
35 box-shadow: 0 0 20px #ccc; -webkit-box-shadow: 0 0 20px #ccc; -moz-box-shadow: 0 0 20px #ccc;
36 }
37 a.toc_title, a.toc_title:visited {
38 display: block;
39 color: black;
40 font-weight: bold;
41 margin-top: 15px;
42 }
43 a.toc_title:hover {
44 text-decoration: underline;
45 }
46 #sidebar .version {
47 font-size: 10px;
48 font-weight: normal;
49 }
50 ul.toc_section {
51 font-size: 11px;
52 line-height: 14px;
53 margin: 5px 0 0 0;
54 padding-left: 0px;
55 list-style-type: none;
56 font-family: Lucida Grande;
57 }
58 .toc_section li {
59 cursor: pointer;
60 margin: 0 0 3px 0;
61 }
62 .toc_section li a {
63 text-decoration: none;
64 color: black;
65 }
66 .toc_section li a:hover {
67 text-decoration: underline;
68 }
69 input#function_filter {
70 width: 80%;
71 }
72 div.container {
73 width: 550px;
74 margin: 40px 0 50px 280px;
75 }
76 img#logo {
77 width: 396px;
78 height: 69px;
79 }
80 div.warning {
81 margin-top: 15px;
82 font: bold 11px Arial;
83 color: #770000;
84 }
85 p {
86 margin: 20px 0;
87 width: 550px;
88 }
89 a, a:visited {
90 color: #444;
91 }
92 a:active, a:hover {
93 color: #000;
94 }
95 h1, h2, h3, h4, h5, h6 {
96 padding-top: 20px;
97 }
98 h2 {
99 font-size: 20px;
100 }
101 b.header {
102 font-size: 16px;
103 line-height: 30px;
104 }
105 span.alias {
106 font-size: 14px;
107 font-style: italic;
108 margin-left: 20px;
109 }
110 a.source {
111 font-variant: small-caps;
112 margin-left: 20px;
113 }
114 a.source + a.source {
115 margin-left: unset;
116 }
117 table, tr, td {
118 margin: 0; padding: 0;
119 }
120 td {
121 padding: 2px 12px 2px 0;
122 }
123 table .rule {
124 height: 1px;
125 background: #ccc;
126 margin: 5px 0;
127 }
128 table .dl-link {
129 white-space: nowrap;
130 }
131 ul {
132 list-style-type: circle;
133 padding: 0 0 0 20px;
134 }
135 li {
136 margin-bottom: 10px;
137 }
138 code, pre, tt {
139 font-family: Monaco, Consolas, "Lucida Console", monospace;
140 font-size: 12px;
141 line-height: 18px;
142 font-style: normal;
143 }
144 tt {
145 padding: 0px 3px;
146 background: #fff;
147 border: 1px solid #ddd;
148 zoom: 1;
149 }
150 code {
151 margin-left: 20px;
152 }
153 pre {
154 font-size: 12px;
155 padding: 2px 0 2px 15px;
156 border-left: 5px solid #bbb;
157 margin: 0px 0 30px;
158 }
159 input[type=checkbox] {
160 position: absolute;
161 top: -9999px;
162 left: -9999px;
163 }
164 label {
165 position: fixed;
166 left:0;
167 display:none;
168 width: 1em;
169 height: 1.5em;
170 padding: .5em 0.5em 0;
171 font-size:1.1em;
172 color:#fff;
173 transition:color .3s ease-in-out;
174 cursor: pointer;
175 user-select:none;
176 margin:0;
177 background:rgba(0, 0, 0, 1);
178 }
179 .overlay {
180 height: 100%;
181 width: 0;
182 position: fixed;
183 z-index: 1;
184 top: 0;
185 left: 0;
186 background-color: rgb(0,0,0);
187 background-color: rgba(0,0,0, 0.9);
188 overflow-x: hidden;
189 transition: 0.5s;
190 }
191
192 @media only screen and (-webkit-min-device-pixel-ratio: 1.5) and (max-width: 640px),
193 only screen and (-o-min-device-pixel-ratio: 3/2) and (max-width: 640px),
194 only screen and (min-device-pixel-ratio: 1.5) and (max-width: 640px) {
195 img {
196 max-width: 100%;
197 }
198 div#sidebar {
199 -webkit-overflow-scrolling: initial;
200 position: relative;
201 width: 100%;
202 height: 100%;
203 left: 0;
204 padding: 20px 0 10px 45px;
205 border: 0;
206 }
207 img#logo {
208 width: auto;
209 height: auto;
210 }
211 div.container {
212 margin: 50px 0;
213 width: 100%;
214
215 }
216 p, div.container ul {
217 max-width: 98%;
218 overflow-x: scroll;
219 }
220 pre {
221 overflow: scroll;
222 }
223 }
224
225 @media screen and (max-width: 640px){
226 body{
227 line-height: 22px;
228 }
229 ul.toc_section {
230 font-size: 14px;
231 line-height: 15px;
232 font-family: Helvetica Neue, Helvetica, Arial;
233 }
234 label {
235 display:block;
236 top:0;
237 z-index:999;
238 }
239 label:after {
240 position: absolute;
241 right: .25em;
242 top: 5px;
243 content:"\2261";
244 font-size:1.8em;
245 }
246 label:hover,
247 input:checked ~ label {
248 color:#fff;
249 }
250 input:checked ~ #myNav{
251 width:0;
252 }
253 #myNav{
254 width: 100%;
255 }
256 .overlay-content {
257 position: relative;
258 top: 25%;
259 width: 100%;
260 }
261 }
262
263 @media screen and (prefers-color-scheme: dark) {
264 body {
265 background: #111 !important;
266 color: #c6c6c6;
267 }
268 div#sidebar {
269 background: #111;
270 border-right: 1px solid #666;
271 box-shadow: 0 0 20px #555;
272 -webkit-box-shadow: 0 0 20px #555;
273 -moz-box-shadow: 0 0 20px #555;
274 }
275 a.toc_title,
276 a.toc_title:visited {
277 color: #f4f4f4;
278 }
279 a.toc_title:hover {
280 text-decoration: underline;
281 }
282 .toc_section li a {
283 text-decoration: none;
284 color: #f4f4f4;
285 }
286 img#logo {
287 filter: invert(1) hue-rotate(180deg) brightness(0.9);
288 }
289 div.warning {
290 color: #CC6060;
291 }
292 a,
293 a:visited {
294 color: #f4f4f4;
295 }
296 a:active,
297 a:hover {
298 color: #ffffff;
299 }
300 table .rule {
301 background: #777;
302 }
303 tt {
304 background: #444;
305 border: 1px solid #777;
306 }
307 pre {
308 border-left: 5px solid #aaa;
309 }
310 }
311 </style>
312 </head>
313 <body>
314
315 <input type="checkbox" id="menu" checked>
316 <label for="menu" role="navigation" aria-label="Menu"></label>
317 <div id="myNav" class="overlay">
318 <div id="sidebar" class="interface overlay-content">
319
320 <a class="toc_title" href="#">
321 Underscore.js <span class="version">(1.13.8)</span>
322 </a>
323
324 <ul class="toc_section">
325 <li>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
326 <li>&raquo; <a href="docs/modules/index-all.html">Annotated Source (modular)</a></li>
327 <li>&raquo; <a href="docs/underscore-esm.html">Annotated Source (single read)</a></li>
328 <li>&raquo; <a href="https://documentcloud.github.io/underscore-contrib/">Underscore-contrib</a></li>
329 <li>&raquo; <a href="https://twitter.com/underscoredotjs">Twitter</a></li>
330 <li>&raquo; <a href="https://tidelift.com/subscription/pkg/npm-underscore?utm_source=npm-underscore&utm_medium=referral&utm_campaign=enterprise">Tidelift</a></li>
331 <li>&raquo; <a href="https://patreon.com/juliangonggrijp">Patreon</a></li>
332 </ul>
333
334 <input id="function_filter" placeholder="Filter" type="text" autofocus />
335
336 <div class="searchable_section">
337 <a class="toc_title" href="#">
338 Introduction
339 </a>
340 </div>
341
342 <div class="searchable_section">
343 <a class="toc_title" href="#collections">
344 Collections
345 </a>
346 <ul class="toc_section">
347 <li data-name="each" data-aliases="forEach">- <a href="#each">each</a></li>
348 <li data-name="map" data-aliases="collect">- <a href="#map">map</a></li>
349 <li data-name="reduce" data-aliases="inject foldl">- <a href="#reduce">reduce</a></li>
350 <li data-name="reduceRight" data-aliases="foldr">- <a href="#reduceRight">reduceRight</a></li>
351 <li data-name="find" data-aliases="detect">- <a href="#find">find</a></li>
352 <li data-name="filter" data-aliases="select">- <a href="#filter">filter</a></li>
353 <li data-name="where">- <a href="#where">where</a></li>
354 <li data-name="findWhere">- <a href="#findWhere">findWhere</a></li>
355 <li data-name="reject">- <a href="#reject">reject</a></li>
356 <li data-name="every" data-aliases="all">- <a href="#every">every</a></li>
357 <li data-name="some" data-aliases="any">- <a href="#some">some</a></li>
358 <li data-name="contains" data-aliases="include includes">- <a href="#contains">contains</a></li>
359 <li data-name="invoke">- <a href="#invoke">invoke</a></li>
360 <li data-name="pluck">- <a href="#pluck">pluck</a></li>
361 <li data-name="max">- <a href="#max">max</a></li>
362 <li data-name="min">- <a href="#min">min</a></li>
363 <li data-name="sortBy">- <a href="#sortBy">sortBy</a></li>
364 <li data-name="groupBy">- <a href="#groupBy">groupBy</a></li>
365 <li data-name="indexBy">- <a href="#indexBy">indexBy</a></li>
366 <li data-name="countBy">- <a href="#countBy">countBy</a></li>
367 <li data-name="shuffle">- <a href="#shuffle">shuffle</a></li>
368 <li data-name="sample">- <a href="#sample">sample</a></li>
369 <li data-name="toArray">- <a href="#toArray">toArray</a></li>
370 <li data-name="size">- <a href="#size">size</a></li>
371 <li data-name="partition">- <a href="#partition">partition</a></li>
372 </ul>
373 </div>
374
375 <div class="searchable_section">
376 <a class="toc_title" href="#arrays">
377 Arrays
378 </a>
379 <ul class="toc_section">
380 <li data-name="first" data-aliases="head take">- <a href="#first">first</a></li>
381 <li data-name="initial">- <a href="#initial">initial</a></li>
382 <li data-name="last">- <a href="#last">last</a></li>
383 <li data-name="rest" data-aliases="tail drop">- <a href="#rest">rest</a></li>
384 <li data-name="compact">- <a href="#compact">compact</a></li>
385 <li data-name="flatten">- <a href="#flatten">flatten</a></li>
386 <li data-name="without">- <a href="#without">without</a></li>
387 <li data-name="union">- <a href="#union">union</a></li>
388 <li data-name="intersection">- <a href="#intersection">intersection</a></li>
389 <li data-name="difference">- <a href="#difference">difference</a></li>
390 <li data-name="uniq" data-aliases="unique">- <a href="#uniq">uniq</a></li>
391 <li data-name="zip">- <a href="#zip">zip</a></li>
392 <li data-name="unzip" data-aliases="transpose">- <a href="#unzip">unzip</a></li>
393 <li data-name="object">- <a href="#object">object</a></li>
394 <li data-name="chunk">- <a href="#chunk">chunk</a></li>
395 <li data-name="indexOf">- <a href="#indexOf">indexOf</a></li>
396 <li data-name="lastIndexOf">- <a href="#lastIndexOf">lastIndexOf</a></li>
397 <li data-name="sortedIndex">- <a href="#sortedIndex">sortedIndex</a></li>
398 <li data-name="findIndex">- <a href="#findIndex">findIndex</a></li>
399 <li data-name="findLastIndex">- <a href="#findLastIndex">findLastIndex</a></li>
400 <li data-name="range">- <a href="#range">range</a></li>
401 </ul>
402 </div>
403
404 <div class="searchable_section">
405 <a class="toc_title" href="#functions">
406 Functions
407 </a>
408 <ul class="toc_section">
409 <li data-name="bind">- <a href="#bind">bind</a></li>
410 <li data-name="bindAll">- <a href="#bindAll">bindAll</a></li>
411 <li data-name="partial">- <a href="#partial">partial</a></li>
412 <li data-name="memoize">- <a href="#memoize">memoize</a></li>
413 <li data-name="delay">- <a href="#delay">delay</a></li>
414 <li data-name="defer">- <a href="#defer">defer</a></li>
415 <li data-name="throttle">- <a href="#throttle">throttle</a></li>
416 <li data-name="debounce">- <a href="#debounce">debounce</a></li>
417 <li data-name="once">- <a href="#once">once</a></li>
418 <li data-name="after">- <a href="#after">after</a></li>
419 <li data-name="before">- <a href="#before">before</a></li>
420 <li data-name="wrap">- <a href="#wrap">wrap</a></li>
421 <li data-name="negate">- <a href="#negate">negate</a></li>
422 <li data-name="compose">- <a href="#compose">compose</a></li>
423 <li data-name="restArguments">- <a href="#restArguments">restArguments</a></li>
424 </ul>
425 </div>
426
427 <div class="searchable_section">
428 <a class="toc_title" href="#objects">
429 Objects
430 </a>
431 <ul class="toc_section">
432 <li data-name="keys">- <a href="#keys">keys</a></li>
433 <li data-name="allKeys">- <a href="#allKeys">allKeys</a></li>
434 <li data-name="values">- <a href="#values">values</a></li>
435 <li data-name="mapObject">- <a href="#mapObject">mapObject</a></li>
436 <li data-name="pairs">- <a href="#pairs">pairs</a></li>
437 <li data-name="invert">- <a href="#invert">invert</a></li>
438 <li data-name="create">- <a href="#create">create</a></li>
439 <li data-name="object-functions" data-aliases="methods">- <a href="#object-functions">functions</a></li>
440 <li data-name="findKey">- <a href="#findKey">findKey</a></li>
441 <li data-name="extend">- <a href="#extend">extend</a></li>
442 <li data-name="extendOwn" data-aliases="assign">- <a href="#extendOwn">extendOwn</a></li>
443 <li data-name="pick">- <a href="#pick">pick</a></li>
444 <li data-name="omit">- <a href="#omit">omit</a></li>
445 <li data-name="defaults">- <a href="#defaults">defaults</a></li>
446 <li data-name="clone">- <a href="#clone">clone</a></li>
447 <li data-name="tap">- <a href="#tap">tap</a></li>
448 <li data-name="toPath">- <a href="#toPath">toPath</a></li>
449 <li data-name="has">- <a href="#has">has</a></li>
450 <li data-name="get">- <a href="#get">get</a></li>
451 <li data-name="property">- <a href="#property">property</a></li>
452 <li data-name="propertyOf">- <a href="#propertyOf">propertyOf</a></li>
453 <li data-name="matcher">- <a href="#matcher">matcher</a></li>
454 <li data-name="isEqual">- <a href="#isEqual">isEqual</a></li>
455 <li data-name="isMatch">- <a href="#isMatch">isMatch</a></li>
456 <li data-name="isEmpty">- <a href="#isEmpty">isEmpty</a></li>
457 <li data-name="isElement">- <a href="#isElement">isElement</a></li>
458 <li data-name="isArray">- <a href="#isArray">isArray</a></li>
459 <li data-name="isObject">- <a href="#isObject">isObject</a></li>
460 <li data-name="isArguments">- <a href="#isArguments">isArguments</a></li>
461 <li data-name="isFunction">- <a href="#isFunction">isFunction</a></li>
462 <li data-name="isString">- <a href="#isString">isString</a></li>
463 <li data-name="isNumber">- <a href="#isNumber">isNumber</a></li>
464 <li data-name="isFinite">- <a href="#isFinite">isFinite</a></li>
465 <li data-name="isBoolean">- <a href="#isBoolean">isBoolean</a></li>
466 <li data-name="isDate">- <a href="#isDate">isDate</a></li>
467 <li data-name="isRegExp">- <a href="#isRegExp">isRegExp</a></li>
468 <li data-name="isError">- <a href="#isError">isError</a></li>
469 <li data-name="isSymbol">- <a href="#isSymbol">isSymbol</a></li>
470 <li data-name="isMap">- <a href="#isMap">isMap</a></li>
471 <li data-name="isWeakMap">- <a href="#isWeakMap">isWeakMap</a></li>
472 <li data-name="isSet">- <a href="#isSet">isSet</a></li>
473 <li data-name="isWeakSet">- <a href="#isWeakSet">isWeakSet</a></li>
474 <li data-name="isArrayBuffer">- <a href="#isArrayBuffer">isArrayBuffer</a></li>
475 <li data-name="isDataView">- <a href="#isDataView">isDataView</a></li>
476 <li data-name="isTypedArray" data-aliases="isInt8Array isUint8Array isUint8ClampedArray isInt16Array isUint16Array isInt32Array isUint32Array isBigInt64Array isBigUint64Array isFloat32Array isFloat64Array">- <a href="#isTypedArray">isTypedArray</a></li>
477 <li data-name="isNaN">- <a href="#isNaN">isNaN</a></li>
478 <li data-name="isNull">- <a href="#isNull">isNull</a></li>
479 <li data-name="isUndefined">- <a href="#isUndefined">isUndefined</a></li>
480 </ul>
481 </div>
482
483 <div class="searchable_section">
484 <a class="toc_title" href="#utility">
485 Utility
486 </a>
487 <ul class="toc_section">
488 <li data-name="noConflict">- <a href="#noConflict">noConflict</a></li>
489 <li data-name="identity">- <a href="#identity">identity</a></li>
490 <li data-name="constant">- <a href="#constant">constant</a></li>
491 <li data-name="noop">- <a href="#noop">noop</a></li>
492 <li data-name="times">- <a href="#times">times</a></li>
493 <li data-name="random">- <a href="#random">random</a></li>
494 <li data-name="mixin">- <a href="#mixin">mixin</a></li>
495 <li data-name="iteratee">- <a href="#iteratee">iteratee</a></li>
496 <li data-name="uniqueId">- <a href="#uniqueId">uniqueId</a></li>
497 <li data-name="escape">- <a href="#escape">escape</a></li>
498 <li data-name="unescape">- <a href="#unescape">unescape</a></li>
499 <li data-name="result">- <a href="#result">result</a></li>
500 <li data-name="now">- <a href="#now">now</a></li>
501 <li data-name="template">- <a href="#template">template</a></li>
502 <li data-name="version">- <a href="#version">version</a></li>
503 </ul>
504 </div>
505
506 <div class="searchable_section">
507 <a class="toc_title" href="#oop" data-name="oop" data-aliases="_() ()">
508 OOP Style
509 </a>
510 </div>
511
512 <div class="searchable_section">
513 <a class="toc_title" href="#chaining">
514 Chaining
515 </a>
516 <ul class="toc_section">
517 <li data-name="chain">- <a href="#chain">chain</a></li>
518 <li data-name="value">- <a href="#value">value</a></li>
519 </ul>
520 </div>
521
522 <div class="searchable_section">
523 <a class="toc_title" href="#links">
524 Links
525 </a>
526 </div>
527
528 <div class="searchable_section">
529 <a class="toc_title" href="#notes">
530 Notes
531 </a>
532 </div>
533
534 <div class="searchable_section">
535 <a class="toc_title" href="#changelog">
536 Change Log
537 </a>
538 </div>
539
540 </div>
541 </div>
542 <div class="container">
543
544 <p id="introduction">
545 <img id="logo" src="docs/images/underscore.png" alt="Underscore.js" />
546 </p>
547
548 <p>
549 <a href="https://github.com/jashkenas/underscore/">Underscore</a>
550 is a JavaScript library that provides a whole mess of useful functional
551 programming helpers without extending any built-in objects.
552 It&rsquo;s the answer to the question: &ldquo;If I sit down in front of a
553 blank HTML page, and want to start being productive immediately, what do I need?&rdquo;
554 &hellip; and the tie to go along with
555 <a href="https://jquery.com">jQuery</a>'s tux and
556 <a href="https://backbonejs.org">Backbone</a>'s suspenders.
557 </p>
558
559 <p>
560 Underscore provides over 100 functions that support both your favorite
561 workaday functional helpers: <b>map</b>, <b>filter</b>, <b>invoke</b> &mdash;
562 as well as more specialized goodies: function binding, javascript
563 templating, creating quick indexes, deep equality testing, and so on.
564 </p>
565
566 <p>
567 A complete <a href="test/">Test Suite</a>
568 is included for your perusal.
569 </p>
570
571 <p>
572 You may also read through the <a
573 href="docs/underscore-esm.html">annotated source code</a>. There is a <a
574 href="docs/modules/index-all.html">modular version</a> with clickable
575 import references as well.
576 </p>
577
578 <p>
579 You may choose between monolithic and modular imports. There is a quick
580 summary of the options below, as well as a more comprehensive
581 discussion in <a
582 href="https://juliangonggrijp.com/article/introducing-modular-underscore.html"
583 >the article</a>.
584 </p>
585
586 <p>
587 Enjoying Underscore, and want to <i>turn it up to 11?</i> Try <a href="https://documentcloud.github.io/underscore-contrib/">Underscore-contrib</a>.
588 </p>
589
590 <p>
591 The project is
592 <a href="https://github.com/jashkenas/underscore">hosted on GitHub</a>.
593 You can report bugs and discuss features on the
594 <a href="https://github.com/jashkenas/underscore/issues">issues page</a>
595 or chat in the <a href="https://gitter.im/jashkenas/underscore">Gitter</a>
596 channel.
597 </p>
598
599 <p>
600 You can support the project by donating on
601 <a href="https://patreon.com/juliangonggrijp">Patreon</a>.
602 Enterprise coverage is available as part of the <a
603 href="https://tidelift.com/subscription/pkg/npm-underscore?utm_source=npm-underscore&utm_medium=referral&utm_campaign=enterprise"
604 >Tidelift Subscription</a>.
605 </p>
606
607 <p>
608 <i>Underscore is an open-source component of <a href="https://documentcloud.org/">DocumentCloud</a>.</i>
609 </p>
610
611 <h2>v1.13.8 Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and use "Save As")</i></h2>
612
613 <table>
614 <tr>
615 <td class="dl-link"><a href="underscore-esm.js">ESM (Development)</a></td>
616 <td>
617 <i>65.9 KB, Uncompressed with Plentiful Comments</i>
618 &nbsp;<small>(<a href="underscore-esm.js.map">Source Map</a>)</small>
619 </td>
620 </tr>
621 <tr>
622 <td class="dl-link"><a href="underscore-esm-min.js">ESM (Production)</a></td>
623 <td>
624 <i>8.59 KB, Minified and Gzipped</i>
625 &nbsp;<small>(<a href="underscore-esm-min.js.map">Source Map</a>)</small>
626 </td>
627 </tr>
628 <tr>
629 <td class="dl-link"><a href="underscore-umd.js">UMD (Development)</a></td>
630 <td>
631 <i>68.4 KB, Uncompressed with Bountiful Comments</i>
632 &nbsp;<small>(<a href="underscore-umd.js.map">Source Map</a>)</small>
633 </td>
634 </tr>
635 <tr>
636 <td class="dl-link"><a href="underscore-umd-min.js">UMD (Production)</a></td>
637 <td>
638 <i>7.48 KB, Minified and Gzipped</i>
639 &nbsp;<small>(<a href="underscore-umd-min.js.map">Source Map</a>)</small>
640 </td>
641 </tr>
642 <tr>
643 <td colspan="2"><div class="rule"></div></td>
644 </tr>
645 <tr>
646 <td class="dl-link"><a href="https://raw.github.com/jashkenas/underscore/master/underscore-esm.js">Edge ESM</a></td>
647 <td><i>Unreleased, current <tt>master</tt>, use by your own judgement and at your own risk</i></td>
648 </tr>
649 <tr>
650 <td class="dl-link"><a href="https://raw.github.com/jashkenas/underscore/master/underscore-umd.js">Edge UMD</a></td>
651 <td><i>Unreleased, current <tt>master</tt>, use if you’re feeling lucky</i></td>
652 </tr>
653 </table>
654
655 <h2>v1.13.8 CDN URLs <i style="padding-left: 12px; font-size:12px;">(Use with <tt>&lt;script src="..."&gt;&lt;/script&gt;</tt>)</i></h2>
656
657 <ul>
658 <li>
659 <tt>https://cdn.jsdelivr.net/npm/[email protected]/underscore-umd-min.js</tt>
660 </li>
661 <li>
662 <tt>https://cdn.jsdelivr.net/npm/[email protected]/underscore-esm-min.js</tt>
663 </li>
664 <li>
665 <tt>https://unpkg.com/[email protected]/underscore-umd-min.js</tt>
666 </li>
667 <li>
668 <tt>https://unpkg.com/[email protected]/underscore-esm-min.js</tt>
669 </li>
670 <li>
671 <tt>https://pagecdn.io/lib/underscore/1.13.8/underscore-umd-min.js</tt>
672 </li>
673 <li>
674 <tt>https://pagecdn.io/lib/underscore/1.13.8/underscore-esm-min.js</tt>
675 </li>
676 <li>
677 <tt>https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.8/underscore-umd-min.js</tt>
678 </li>
679 <li>
680 <tt>https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.8/underscore-esm-min.js</tt>
681 </li>
682 </ul>
683
684 <p>
685 <i>In most cases, you can replace the version number above by
686 <tt>latest</tt> so that your embed will automatically use the latest
687 version, or <tt>stable</tt> if you want to delay updating until an update
688 has proven to be free of accidental breaking changes. Example:</i><br>
689 <tt>https://cdn.jsdelivr.net/npm/underscore@latest/underscore-umd-min.js</tt>
690 </p>
691
692 <h2>Package Installation</h2>
693
694 <ul>
695 <li>
696 <b>Node.js</b> <tt>npm install underscore</tt>
697 </li>
698 <li>
699 <b>Meteor.js</b> <tt>meteor add underscore</tt>
700 </li>
701 <li>
702 <b>Bower</b> <tt>bower install underscore</tt>
703 </li>
704 </ul>
705
706 <p>
707 <i>If you are hardcoding the path to the file within the package and you
708 are unsure which build to use, it is very likely that you need
709 <tt>underscore-umd.js</tt> or the minified variant
710 <tt>underscore-umd-min.js</tt>.</i>
711 </p>
712
713 <h2>Monolithic Import (recommended)</h2>
714
715 <ul>
716 <li>
717 <b>ESM</b> <tt>import _, { map } from 'underscore';</tt>
718 </li>
719 <li>
720 <b>AMD</b> <tt>require(['underscore'], ...)</tt>
721 </li>
722 <li>
723 <b>CommonJS</b> <tt>var _ = require('underscore');</tt>
724 </li>
725 <li>
726 <b>ExtendScript</b> <tt>#include "underscore-umd.js"</tt>
727 </li>
728 </ul>
729
730 <h2>Modular Import</h2>
731
732 <ul>
733 <li>
734 <b>ESM</b> <tt>import map from 'underscore/modules/map.js'</tt>
735 </li>
736 <li>
737 <b>AMD</b> <tt>require(['underscore/amd/map.js'], ...)</tt>
738 </li>
739 <li>
740 <b>CommonJS</b> <tt>var map = require('underscore/cjs/map.js');</tt>
741 </li>
742 </ul>
743
744 <p>
745 <i>For functions with multiple aliases, the file name of the module is
746 always the <b>first</b> name that appears in the documentation. For
747 example, <tt>_.reduce</tt>/<tt>_.inject</tt>/<tt>_.foldl</tt> is exported
748 from <tt>underscore/modules/reduce.js</tt>. Modular usage is mostly
749 recommended for creating a customized build of Underscore.</i>
750 </p>
751
752 <h2 id=compatibility>Engine Compatibility</h2>
753
754 <p>
755 Underscore 1.x is backwards compatible with any engine that fully
756 supports ES3, while also utilizing newer features when available, such as
757 <tt>Object.keys</tt>, typed arrays and ES modules. We routinely run our
758 unittests against the JavaScript engines listed below:
759 </p>
760
761 <ul>
762 <li>Chrome 26&ndash;latest</li>
763 <li>Edge 13, 18 and latest</li>
764 <li>Firefox 11&ndash;latest</li>
765 <li>Internet Explorer 9&ndash;11</li>
766 <li>Node.js 8&ndash;latest LTS</li>
767 <li>Safari 8&ndash;latest</li>
768 </ul>
769
770 <p>
771 In addition:
772 </p>
773
774 <ul>
775 <li>
776 We have recent confirmation that the library is compatible with Adobe
777 ExtendScript.
778 </li>
779 <li>
780 There is support code present for IE 8, which we will retain in
781 future Underscore 1.x updates.
782 </li>
783 <li>
784 Patches to enhance support for other ES3-compatible environments
785 are always welcome.
786 </li>
787 </ul>
788
789 <p>
790 Underscore 2.x will likely remove support for some outdated environments.
791 </p>
792
793 <div id="documentation">
794
795 <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
796
797 <p id="each">
798 <b class="header">each</b><code>_.each(list, iteratee, [context])</code>
799 <span class="alias">Alias: <b>forEach</b></span>
800 <a href="docs/modules/each.html" class="source">source</a>
801 <br />
802 Iterates over a <b>list</b> of elements, yielding each in turn to an
803 <b>iteratee</b> function.
804 The <b>iteratee</b> is bound to the <b>context</b> object, if one is
805 passed. Each invocation of <b>iteratee</b> is called with three arguments:
806 <tt>(element, index, list)</tt>. If <b>list</b> is a JavaScript object, <b>iteratee</b>'s
807 arguments will be <tt>(value, key, list)</tt>. Returns the <b>list</b> for chaining.
808 </p>
809 <pre>
810 _.each([1, 2, 3], alert);
811 =&gt; alerts each number in turn...
812 _.each({one: 1, two: 2, three: 3}, alert);
813 =&gt; alerts each number value in turn...</pre>
814
815 <p>
816 <i>
817 Note: Collection functions work on arrays, objects, and
818 array-like objects such as</i> <tt>arguments</tt>, <tt>NodeList</tt><i>
819 and similar. But it works by duck-typing, so avoid passing objects with
820 a numeric <tt>length</tt> property. It's also good to note that an
821 <tt>each</tt> loop cannot be broken out of — to break, use <b>_.find</b>
822 instead.
823 </i>
824 </p>
825
826 <p id="map">
827 <b class="header">map</b><code>_.map(list, iteratee, [context])</code>
828 <span class="alias">Alias: <b>collect</b></span>
829 <a href="docs/modules/map.html" class="source">source</a>
830 <br />
831 Produces a new array of values by mapping each value in <b>list</b>
832 through a transformation function (<a href="#iteratee"><b>iteratee</b></a>).
833 The iteratee is passed three arguments: the <tt>value</tt>,
834 then the <tt>index</tt> (or <tt>key</tt>) of the iteration,
835 and finally a reference to the entire <tt>list</tt>.
836 </p>
837 <pre>
838 _.map([1, 2, 3], function(num){ return num * 3; });
839 =&gt; [3, 6, 9]
840 _.map({one: 1, two: 2, three: 3}, function(num, key){ return num * 3; });
841 =&gt; [3, 6, 9]
842 _.map([[1, 2], [3, 4]], _.first);
843 =&gt; [1, 3]</pre>
844
845 <p id="reduce">
846 <b class="header">reduce</b><code>_.reduce(list, iteratee, [memo], [context])</code>
847 <span class="alias">Aliases: <b>inject</b>, <b>foldl</b></span>
848 <a href="docs/modules/reduce.html" class="source">source</a>
849 <br />
850 Also known as <b>inject</b> and <b>foldl</b>, reduce boils down a <b>list</b> of values into a single value.
851 <b>Memo</b> is the initial state of the reduction, and each successive step of it should be returned by
852 <b>iteratee</b>. The iteratee is passed four arguments: the <tt>memo</tt>, then the <tt>value</tt> and
853 <tt>index</tt> (or key) of the iteration, and finally a reference to the entire <tt>list</tt>.
854 </p>
855 <p>
856 If no memo is passed to the initial invocation of reduce, the iteratee is not invoked on the first element
857 of the list. The first element is instead passed as the memo in the invocation of the iteratee on the next
858 element in the list.
859 </p>
860 <pre>
861 var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
862 =&gt; 6
863 </pre>
864
865 <p id="reduceRight">
866 <b class="header">reduceRight</b><code>_.reduceRight(list, iteratee, [memo], [context])</code>
867 <span class="alias">Alias: <b>foldr</b></span>
868 <a href="docs/modules/reduceRight.html" class="source">source</a>
869 <br />
870 The right-associative version of <b>reduce</b>. <b>Foldr</b>
871 is not as useful in JavaScript as it would be in a language with lazy
872 evaluation.
873 </p>
874 <pre>
875 var list = [[0, 1], [2, 3], [4, 5]];
876 var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
877 =&gt; [4, 5, 2, 3, 0, 1]
878 </pre>
879
880 <p id="find">
881 <b class="header">find</b><code>_.find(list, predicate, [context])</code>
882 <span class="alias">Alias: <b>detect</b></span>
883 <a href="docs/modules/find.html" class="source">source</a>
884 <br />
885 Looks through each value in the <b>list</b>, returning the first one that
886 passes a truth test (<b>predicate</b>), or <tt>undefined</tt> if no value
887 passes the test. The function returns as
888 soon as it finds an acceptable element, and doesn't traverse the
889 entire list.
890 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
891 to facilitate shorthand syntaxes.
892 </p>
893 <pre>
894 var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
895 =&gt; 2
896 </pre>
897
898 <p id="filter">
899 <b class="header">filter</b><code>_.filter(list, predicate, [context])</code>
900 <span class="alias">Alias: <b>select</b></span>
901 <a href="docs/modules/filter.html" class="source">source</a>
902 <br />
903 Looks through each value in the <b>list</b>, returning an array of all
904 the values that pass a truth test (<b>predicate</b>).
905 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
906 to facilitate shorthand syntaxes.
907 </p>
908 <pre>
909 var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
910 =&gt; [2, 4, 6]
911 </pre>
912
913 <p id="findWhere">
914 <b class="header">findWhere</b><code>_.findWhere(list, properties)</code>
915 <a href="docs/modules/findWhere.html" class="source">source</a>
916 <br />
917 Looks through the <b>list</b> and returns the <i>first</i> value that <a href="#matches">matches</a>
918 all of the key-value pairs listed in <b>properties</b>.
919 </p>
920 <p>
921 If no match is found, or if <b>list</b> is empty, <i>undefined</i> will be
922 returned.
923 </p>
924 <pre>
925 _.findWhere(publicServicePulitzers, {newsroom: "The New York Times"});
926 =&gt; {year: 1918, newsroom: "The New York Times",
927 reason: "For its public service in publishing in full so many official reports,
928 documents and speeches by European statesmen relating to the progress and
929 conduct of the war."}
930 </pre>
931
932 <p id="where">
933 <b class="header">where</b><code>_.where(list, properties)</code>
934 <a href="docs/modules/where.html" class="source">source</a>
935 <br />
936 Looks through each value in the <b>list</b>, returning an array of all
937 the values that <a href="#matches">matches</a> the key-value pairs listed in <b>properties</b>.
938 </p>
939 <pre>
940 _.where(listOfPlays, {author: "Shakespeare", year: 1611});
941 =&gt; [{title: "Cymbeline", author: "Shakespeare", year: 1611},
942 {title: "The Tempest", author: "Shakespeare", year: 1611}]
943 </pre>
944
945 <p id="reject">
946 <b class="header">reject</b><code>_.reject(list, predicate, [context])</code>
947 <a href="docs/modules/reject.html" class="source">source</a>
948 <br />
949 Returns the values in <b>list</b> without the elements that the truth
950 test (<b>predicate</b>) passes. The opposite of <b>filter</b>.
951 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
952 to facilitate shorthand syntaxes.
953 </p>
954 <pre>
955 var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
956 =&gt; [1, 3, 5]
957 </pre>
958
959 <p id="every">
960 <b class="header">every</b><code>_.every(list, [predicate], [context])</code>
961 <span class="alias">Alias: <b>all</b></span>
962 <a href="docs/modules/every.html" class="source">source</a>
963 <br />
964 Returns <i>true</i> if all of the values in the <b>list</b> pass the
965 <b>predicate</b> truth test. Short-circuits and stops traversing the list
966 if a false element is found.
967 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
968 to facilitate shorthand syntaxes.
969 </p>
970 <pre>
971 _.every([2, 4, 5], function(num) { return num % 2 == 0; });
972 =&gt; false
973 </pre>
974
975 <p id="some">
976 <b class="header">some</b><code>_.some(list, [predicate], [context])</code>
977 <span class="alias">Alias: <b>any</b></span>
978 <a href="docs/modules/some.html" class="source">source</a>
979 <br />
980 Returns <i>true</i> if any of the values in the <b>list</b> pass the
981 <b>predicate</b> truth test. Short-circuits and stops traversing the list
982 if a true element is found.
983 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
984 to facilitate shorthand syntaxes.
985 </p>
986 <pre>
987 _.some([null, 0, 'yes', false]);
988 =&gt; true
989 </pre>
990
991 <p id="contains">
992 <b class="header">contains</b><code>_.contains(list, value, [fromIndex])</code>
993 <span class="alias">Aliases: <b>include</b>, <b>includes</b></span>
994 <a href="docs/modules/contains.html" class="source">source</a>
995 <br />
996 Returns <i>true</i> if the <b>value</b> is present in the <b>list</b>.
997 Uses <b>indexOf</b> internally, if <b>list</b> is an Array.
998 Use <b>fromIndex</b> to start your search at a given index.
999 </p>
1000 <pre>
1001 _.contains([1, 2, 3], 3);
1002 =&gt; true
1003 </pre>
1004
1005 <p id="invoke">
1006 <b class="header">invoke</b><code>_.invoke(list, methodName, *arguments)</code>
1007 <a href="docs/modules/invoke.html" class="source">source</a>
1008 <br />
1009 Calls the method named by <b>methodName</b> on each value in the <b>list</b>.
1010 Any extra arguments passed to <b>invoke</b> will be forwarded on to the
1011 method invocation.
1012 </p>
1013 <pre>
1014 _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
1015 =&gt; [[1, 5, 7], [1, 2, 3]]
1016 </pre>
1017
1018 <p id="pluck">
1019 <b class="header">pluck</b><code>_.pluck(list, propertyName)</code>
1020 <a href="docs/modules/pluck.html" class="source">source</a>
1021 <br />
1022 A convenient version of what is perhaps the most common use-case for
1023 <b>map</b>: extracting a list of property values.
1024 </p>
1025 <pre>
1026 var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
1027 _.pluck(stooges, 'name');
1028 =&gt; ["moe", "larry", "curly"]
1029 </pre>
1030
1031 <p id="max">
1032 <b class="header">max</b><code>_.max(list, [iteratee], [context])</code>
1033 <a href="docs/modules/max.html" class="source">source</a>
1034 <br />
1035 Returns the maximum value in <b>list</b>. If an <a href="#iteratee"><b>iteratee</b></a>
1036 function is provided, it will be used on each value to generate the
1037 criterion by which the value is ranked. <i>-Infinity</i> is returned
1038 if <b>list</b> is empty, so an <a href="#isEmpty">isEmpty</a> guard
1039 may be required. This function can currently only compare numbers reliably.
1040 This function uses operator <tt>&lt;</tt>
1041 (<a href="#relational-operator-note">note</a>).
1042 </p>
1043 <pre>
1044 var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
1045 _.max(stooges, function(stooge){ return stooge.age; });
1046 =&gt; {name: 'curly', age: 60};
1047 </pre>
1048
1049 <p id="min">
1050 <b class="header">min</b><code>_.min(list, [iteratee], [context])</code>
1051 <a href="docs/modules/min.html" class="source">source</a>
1052 <br />
1053 Returns the minimum value in <b>list</b>. If an <a href="#iteratee"><b>iteratee</b></a>
1054 function is provided, it will be used on each value to generate the
1055 criterion by which the value is ranked. <i>Infinity</i> is returned
1056 if <b>list</b> is empty, so an <a href="#isEmpty">isEmpty</a> guard
1057 may be required. This function can currently only compare numbers reliably.
1058 This function uses operator <tt>&lt;</tt>
1059 (<a href="#relational-operator-note">note</a>).
1060 </p>
1061 <pre>
1062 var numbers = [10, 5, 100, 2, 1000];
1063 _.min(numbers);
1064 =&gt; 2
1065 </pre>
1066
1067 <p id="sortBy">
1068 <b class="header">sortBy</b><code>_.sortBy(list, iteratee, [context])</code>
1069 <a href="docs/modules/sortBy.html" class="source">source</a>
1070 <br />
1071 Returns a (stably) sorted copy of <b>list</b>, ranked in ascending
1072 order by the results of running each value through <a href="#iteratee"><b>iteratee</b></a>.
1073 iteratee may also be the string name of the property to sort by (eg.
1074 <tt>length</tt>). This function uses operator <tt>&lt;</tt>
1075 (<a href="#relational-operator-note">note</a>).
1076 </p>
1077 <pre>
1078 _.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });
1079 =&gt; [5, 4, 6, 3, 1, 2]
1080
1081 var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
1082 _.sortBy(stooges, 'name');
1083 =&gt; [{name: 'curly', age: 60}, {name: 'larry', age: 50}, {name: 'moe', age: 40}];
1084 </pre>
1085 <p id="groupBy">
1086 <b class="header">groupBy</b><code>_.groupBy(list, iteratee, [context])</code>
1087 <a href="docs/modules/groupBy.html" class="source">source</a>
1088 <br />
1089 Splits a collection into sets, grouped by the result of running each
1090 value through <b>iteratee</b>. If <b>iteratee</b> is a string instead of
1091 a function, groups by the property named by <b>iteratee</b> on each of
1092 the values.
1093 </p>
1094 <pre>
1095 _.groupBy([1.3, 2.1, 2.4], function(num){ return Math.floor(num); });
1096 =&gt; {1: [1.3], 2: [2.1, 2.4]}
1097
1098 _.groupBy(['one', 'two', 'three'], 'length');
1099 =&gt; {3: ["one", "two"], 5: ["three"]}
1100 </pre>
1101
1102 <p id="indexBy">
1103 <b class="header">indexBy</b><code>_.indexBy(list, iteratee, [context])</code>
1104 <a href="docs/modules/indexBy.html" class="source">source</a>
1105 <br />
1106 Given a <b>list</b>, and an <a href="#iteratee"><b>iteratee</b></a> function
1107 that returns a key for each element in the list (or a property name),
1108 returns an object with an index of each item.
1109 Just like <a href="#groupBy">groupBy</a>, but for when you know your
1110 keys are unique.
1111 </p>
1112 <pre>
1113 var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
1114 _.indexBy(stooges, 'age');
1115 =&gt; {
1116 "40": {name: 'moe', age: 40},
1117 "50": {name: 'larry', age: 50},
1118 "60": {name: 'curly', age: 60}
1119 }
1120 </pre>
1121
1122 <p id="countBy">
1123 <b class="header">countBy</b><code>_.countBy(list, iteratee, [context])</code>
1124 <a href="docs/modules/countBy.html" class="source">source</a>
1125 <br />
1126 Sorts a list into groups and returns a count for the number of objects
1127 in each group.
1128 Similar to <tt>groupBy</tt>, but instead of returning a list of values,
1129 returns a count for the number of values in that group.
1130 </p>
1131 <pre>
1132 _.countBy([1, 2, 3, 4, 5], function(num) {
1133 return num % 2 == 0 ? 'even': 'odd';
1134 });
1135 =&gt; {odd: 3, even: 2}
1136 </pre>
1137
1138 <p id="shuffle">
1139 <b class="header">shuffle</b><code>_.shuffle(list)</code>
1140 <a href="docs/modules/shuffle.html" class="source">source</a>
1141 <br />
1142 Returns a shuffled copy of the <b>list</b>, using a version of the
1143 <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle</a>.
1144 </p>
1145 <pre>
1146 _.shuffle([1, 2, 3, 4, 5, 6]);
1147 =&gt; [4, 1, 6, 3, 5, 2]
1148 </pre>
1149
1150 <p id="sample">
1151 <b class="header">sample</b><code>_.sample(list, [n])</code>
1152 <a href="docs/modules/sample.html" class="source">source</a>
1153 <br />
1154 Produce a random sample from the <b>list</b>. Pass a number to
1155 return <b>n</b> random elements from the list. Otherwise a single random
1156 item will be returned.
1157 </p>
1158 <pre>
1159 _.sample([1, 2, 3, 4, 5, 6]);
1160 =&gt; 4
1161
1162 _.sample([1, 2, 3, 4, 5, 6], 3);
1163 =&gt; [1, 6, 2]
1164 </pre>
1165
1166 <p id="toArray">
1167 <b class="header">toArray</b><code>_.toArray(list)</code>
1168 <a href="docs/modules/toArray.html" class="source">source</a>
1169 <br />
1170 Creates a real Array from the <b>list</b> (anything that can be
1171 iterated over). Useful for transmuting the <b>arguments</b> object.
1172 </p>
1173 <pre>
1174 (function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
1175 =&gt; [2, 3, 4]
1176 </pre>
1177
1178 <p id="size">
1179 <b class="header">size</b><code>_.size(list)</code>
1180 <a href="docs/modules/size.html" class="source">source</a>
1181 <br />
1182 Return the number of values in the <b>list</b>.
1183 </p>
1184 <pre>
1185 _.size([1, 2, 3, 4, 5]);
1186 =&gt; 5
1187
1188 _.size({one: 1, two: 2, three: 3});
1189 =&gt; 3
1190 </pre>
1191
1192 <p id="partition">
1193 <b class="header">partition</b><code>_.partition(list, predicate)</code>
1194 <a href="docs/modules/partition.html" class="source">source</a>
1195 <br />
1196 Split <b>list</b> into two arrays: one whose elements all satisfy
1197 <b>predicate</b> and one whose elements all do not satisfy <b>predicate</b>.
1198 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
1199 to facilitate shorthand syntaxes.
1200 </p>
1201 <pre>
1202 _.partition([0, 1, 2, 3, 4, 5], isOdd);
1203 =&gt; [[1, 3, 5], [0, 2, 4]]
1204 </pre>
1205
1206 <p id="compact">
1207 <b class="header">compact</b><code>_.compact(list)</code>
1208 <a href="docs/modules/compact.html" class="source">source</a>
1209 <br />
1210 Returns a copy of the <b>list</b> with all falsy values removed.
1211 In JavaScript, <i>false</i>, <i>null</i>, <i>0</i>, <i>""</i>,
1212 <i>undefined</i> and <i>NaN</i> are all falsy.
1213 </p>
1214 <pre>
1215 _.compact([0, 1, false, 2, '', 3]);
1216 =&gt; [1, 2, 3]
1217 </pre>
1218
1219 <h2 id="arrays">Array Functions</h2>
1220
1221 <p>
1222 <i>
1223 Note: All array functions will also work on the <b>arguments</b> object.
1224 However, Underscore functions are not designed to work on "sparse" arrays.
1225 </i>
1226 </p>
1227
1228 <p id="first">
1229 <b class="header">first</b><code>_.first(array, [n])</code>
1230 <span class="alias">Aliases: <b>head</b>, <b>take</b></span>
1231 <a href="docs/modules/first.html" class="source">source</a>
1232 <br />
1233 Returns the first element of an <b>array</b>. Passing <b>n</b> will
1234 return the first <b>n</b> elements of the array.
1235 </p>
1236 <pre>
1237 _.first([5, 4, 3, 2, 1]);
1238 =&gt; 5
1239 </pre>
1240
1241 <p id="initial">
1242 <b class="header">initial</b><code>_.initial(array, [n])</code>
1243 <a href="docs/modules/initial.html" class="source">source</a>
1244 <br />
1245 Returns everything but the last entry of the array. Especially useful on
1246 the arguments object. Pass <b>n</b> to exclude the last <b>n</b> elements
1247 from the result.
1248 </p>
1249 <pre>
1250 _.initial([5, 4, 3, 2, 1]);
1251 =&gt; [5, 4, 3, 2]
1252 </pre>
1253
1254 <p id="last">
1255 <b class="header">last</b><code>_.last(array, [n])</code>
1256 <a href="docs/modules/last.html" class="source">source</a>
1257 <br />
1258 Returns the last element of an <b>array</b>. Passing <b>n</b> will return
1259 the last <b>n</b> elements of the array.
1260 </p>
1261 <pre>
1262 _.last([5, 4, 3, 2, 1]);
1263 =&gt; 1
1264 </pre>
1265
1266 <p id="rest">
1267 <b class="header">rest</b><code>_.rest(array, [index])</code>
1268 <span class="alias">Aliases: <b>tail</b>, <b>drop</b></span>
1269 <a href="docs/modules/rest.html" class="source">source</a>
1270 <br />
1271 Returns the <b>rest</b> of the elements in an array. Pass an <b>index</b>
1272 to return the values of the array from that index onward.
1273 </p>
1274 <pre>
1275 _.rest([5, 4, 3, 2, 1]);
1276 =&gt; [4, 3, 2, 1]
1277 </pre>
1278
1279 <p id="flatten">
1280 <b class="header">flatten</b><code>_.flatten(array, [depth])</code>
1281 <a href="docs/modules/flatten.html" class="source">source</a>
1282 <br />
1283 Flattens a nested <b>array</b>. If you pass <tt>true</tt> or <tt>1</tt>
1284 as the <b>depth</b>, the array will only be flattened a single level.
1285 Passing a greater number will cause the flattening to descend deeper
1286 into the nesting hierarchy. Omitting the <b>depth</b> argument, or
1287 passing <tt>false</tt> or <tt>Infinity</tt>, flattens the array all the
1288 way to the deepest nesting level.
1289 </p>
1290 <pre>
1291 _.flatten([1, [2], [3, [[4]]]]);
1292 =&gt; [1, 2, 3, 4];
1293
1294 _.flatten([1, [2], [3, [[4]]]], true);
1295 =&gt; [1, 2, 3, [[4]]];
1296
1297 _.flatten([1, [2], [3, [[4]]]], 2);
1298 =&gt; [1, 2, 3, [4]];
1299 </pre>
1300
1301 <p id="without">
1302 <b class="header">without</b><code>_.without(array, *values)</code>
1303 <a href="docs/modules/without.html" class="source">source</a>
1304 <br />
1305 Returns a copy of the <b>array</b> with all instances of the <b>values</b>
1306 removed.
1307 </p>
1308 <pre>
1309 _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
1310 =&gt; [2, 3, 4]
1311 </pre>
1312
1313 <p id="union">
1314 <b class="header">union</b><code>_.union(*arrays)</code>
1315 <a href="docs/modules/union.html" class="source">source</a>
1316 <br />
1317 Computes the union of the passed-in <b>arrays</b>: the list of unique items,
1318 in order, that are present in one or more of the <b>arrays</b>.
1319 </p>
1320 <pre>
1321 _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
1322 =&gt; [1, 2, 3, 101, 10]
1323 </pre>
1324
1325 <p id="intersection">
1326 <b class="header">intersection</b><code>_.intersection(*arrays)</code>
1327 <a href="docs/modules/intersection.html" class="source">source</a>
1328 <br />
1329 Computes the list of values that are the intersection of all the <b>arrays</b>.
1330 Each value in the result is present in each of the <b>arrays</b>.
1331 </p>
1332 <pre>
1333 _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
1334 =&gt; [1, 2]
1335 </pre>
1336
1337 <p id="difference">
1338 <b class="header">difference</b><code>_.difference(array, *others)</code>
1339 <a href="docs/modules/difference.html" class="source">source</a>
1340 <br />
1341 Similar to <b>without</b>, but returns the values from <b>array</b> that
1342 are not present in the <b>other</b> arrays.
1343 </p>
1344 <pre>
1345 _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
1346 =&gt; [1, 3, 4]
1347 </pre>
1348
1349 <p id="uniq">
1350 <b class="header">uniq</b><code>_.uniq(array, [isSorted], [iteratee])</code>
1351 <span class="alias">Alias: <b>unique</b></span>
1352 <a href="docs/modules/uniq.html" class="source">source</a>
1353 <br />
1354 Produces a duplicate-free version of the <b>array</b>, using <i>===</i> to test
1355 object equality. In particular only the first occurrence of each value is kept.
1356 If you know in advance that the <b>array</b> is sorted,
1357 passing <i>true</i> for <b>isSorted</b> will run a much faster algorithm.
1358 If you want to compute unique items based on a transformation, pass an
1359 <a href="#iteratee"><b>iteratee</b></a> function.
1360 </p>
1361 <pre>
1362 _.uniq([1, 2, 1, 4, 1, 3]);
1363 =&gt; [1, 2, 4, 3]
1364 </pre>
1365
1366 <p id="zip">
1367 <b class="header">zip</b><code>_.zip(*arrays)</code>
1368 <a href="docs/modules/zip.html" class="source">source</a>
1369 <br />
1370 Merges together the values of each of the <b>arrays</b> with the
1371 values at the corresponding position. Useful when you have separate
1372 data sources that are coordinated through matching array indexes.
1373 </p>
1374 <pre>
1375 _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
1376 =&gt; [["moe", 30, true], ["larry", 40, false], ["curly", 50, false]]
1377
1378 </pre>
1379
1380 <p id="unzip">
1381 <b class="header">unzip</b><code>_.unzip(array)</code>
1382 <span class="alias">Alias: <b>transpose</b></span>
1383 <a href="docs/modules/unzip.html" class="source">source</a>
1384 <br>
1385 The opposite of <a href="#zip">zip</a>. Given an <b>array</b> of
1386 arrays, returns a series of new arrays, the first of which contains all
1387 of the first elements in the input arrays, the second of which contains
1388 all of the second elements, and so on. If you're working with a matrix
1389 of nested arrays, this can be used to transpose the matrix.
1390 </p>
1391 <pre>
1392 _.unzip([["moe", 30, true], ["larry", 40, false], ["curly", 50, false]]);
1393 =&gt; [['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]]
1394 </pre>
1395
1396 <p id="object">
1397 <b class="header">object</b><code>_.object(list, [values])</code>
1398 <a href="docs/modules/object.html" class="source">source</a>
1399 <br />
1400 Converts arrays into objects. Pass either a single list of
1401 <tt>[key, value]</tt> pairs, or a list of keys, and a list of values. Passing
1402 by pairs is the reverse of <a href="#pairs">pairs</a>. If duplicate keys exist,
1403 the last value wins.
1404 </p>
1405 <pre>
1406 _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
1407 =&gt; {moe: 30, larry: 40, curly: 50}
1408
1409 _.object([['moe', 30], ['larry', 40], ['curly', 50]]);
1410 =&gt; {moe: 30, larry: 40, curly: 50}
1411 </pre>
1412
1413 <p id="chunk">
1414 <b class="header">chunk</b><code>_.chunk(array, length)</code>
1415 <a href="docs/modules/chunk.html" class="source">source</a>
1416 <br />
1417 Chunks an <b>array</b> into multiple arrays, each containing <b>length</b>
1418 or fewer items.
1419 </p>
1420 <pre>
1421 var partners = _.chunk(_.shuffle(kindergarten), 2);
1422 =&gt; [["Tyrone", "Elie"], ["Aidan", "Sam"], ["Katrina", "Billie"], ["Little Timmy"]]
1423 </pre>
1424
1425 <p id="indexOf">
1426 <b class="header">indexOf</b><code>_.indexOf(array, value, [isSorted])</code>
1427 <a href="docs/modules/indexOf.html" class="source">source</a>
1428 <br />
1429 Returns the index at which <b>value</b> can be found in the <b>array</b>,
1430 or <i>-1</i> if value is not present in the <b>array</b>. If you're working with a
1431 large array, and you know that the array is already sorted, pass <tt>true</tt>
1432 for <b>isSorted</b> to use a faster binary search ... or, pass a number as
1433 the third argument in order to look for the first matching value in the
1434 array after the given index. If <tt>isSorted</tt> is <tt>true</tt>,
1435 this function uses operator <tt>&lt;</tt>
1436 (<a href="#relational-operator-note">note</a>).
1437 </p>
1438 <pre>
1439 _.indexOf([1, 2, 3], 2);
1440 =&gt; 1
1441 </pre>
1442
1443 <p id="lastIndexOf">
1444 <b class="header">lastIndexOf</b><code>_.lastIndexOf(array, value, [fromIndex])</code>
1445 <a href="docs/modules/lastIndexOf.html" class="source">source</a>
1446 <br />
1447 Returns the index of the last occurrence of <b>value</b> in the <b>array</b>,
1448 or <i>-1</i> if value is not present. Pass <b>fromIndex</b> to start your search at a
1449 given index.
1450 </p>
1451 <pre>
1452 _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
1453 =&gt; 4
1454 </pre>
1455
1456 <p id="sortedIndex">
1457 <b class="header">sortedIndex</b><code>_.sortedIndex(array, value, [iteratee], [context])</code>
1458 <a href="docs/modules/sortedIndex.html" class="source">source</a>
1459 <br />
1460 Uses a binary search to determine the smallest index at which the <b>value</b>
1461 <i>should</i> be inserted into the <b>array</b> in order to maintain the <b>array</b>'s
1462 sorted order. If an <a href="#iteratee"><b>iteratee</b></a> function is provided,
1463 it will be used to compute the sort ranking of each value, including the <b>value</b> you pass.
1464 The iteratee may also be the string name of the property to sort by
1465 (eg. <tt>length</tt>). This function uses operator <tt>&lt;</tt>
1466 (<a href="#relational-operator-note">note</a>).
1467 </p>
1468 <pre>
1469 _.sortedIndex([10, 20, 30, 40, 50], 35);
1470 =&gt; 3
1471
1472 var stooges = [{name: 'moe', age: 40}, {name: 'curly', age: 60}];
1473 _.sortedIndex(stooges, {name: 'larry', age: 50}, 'age');
1474 =&gt; 1
1475 </pre>
1476
1477 <p id="findIndex">
1478 <b class="header">findIndex</b><code>_.findIndex(array, predicate, [context])</code>
1479 <a href="docs/modules/findIndex.html" class="source">source</a>
1480 <br />
1481 Similar to <a href="#indexOf"><tt>_.indexOf</tt></a>, returns the first index
1482 where the <strong>predicate</strong> truth test passes; otherwise returns <i>-1</i>.
1483 </p>
1484 <pre>
1485 _.findIndex([4, 6, 8, 12], isPrime);
1486 =&gt; -1 // not found
1487 _.findIndex([4, 6, 7, 12], isPrime);
1488 =&gt; 2
1489 </pre>
1490
1491 <p id="findLastIndex">
1492 <b class="header">findLastIndex</b><code>_.findLastIndex(array, predicate, [context])</code>
1493 <a href="docs/modules/findLastIndex.html" class="source">source</a>
1494 <br />
1495 Like <a href="#findIndex"><tt>_.findIndex</tt></a> but iterates the array in reverse,
1496 returning the index closest to the end where the <strong>predicate</strong> truth test
1497 passes.
1498 </p>
1499 <pre>
1500 var users = [{'id': 1, 'name': 'Bob', 'last': 'Brown'},
1501 {'id': 2, 'name': 'Ted', 'last': 'White'},
1502 {'id': 3, 'name': 'Frank', 'last': 'James'},
1503 {'id': 4, 'name': 'Ted', 'last': 'Jones'}];
1504 _.findLastIndex(users, {
1505 name: 'Ted'
1506 });
1507 =&gt; 3
1508 </pre>
1509
1510 <p id="range">
1511 <b class="header">range</b><code>_.range([start], stop, [step])</code>
1512 <a href="docs/modules/range.html" class="source">source</a>
1513 <br />
1514 A function to create flexibly-numbered lists of integers, handy for
1515 <tt>each</tt> and <tt>map</tt> loops. <b>start</b>, if omitted,
1516 defaults to <i>0</i>; <b>step</b> defaults to <i>1</i> if <b>start</b>
1517 is before <b>stop</b>, otherwise <i>-1</i>. Returns a list
1518 of integers from <b>start</b> (inclusive) to <b>stop</b> (exclusive),
1519 incremented (or decremented) by <b>step</b>.
1520 </p>
1521 <pre>
1522 _.range(10);
1523 =&gt; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
1524 _.range(1, 11);
1525 =&gt; [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1526 _.range(0, 30, 5);
1527 =&gt; [0, 5, 10, 15, 20, 25]
1528 _.range(0, -10, -1);
1529 =&gt; [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
1530 _.range(0);
1531 =&gt; []
1532 </pre>
1533
1534 <h2 id="functions">Function (uh, ahem) Functions</h2>
1535
1536 <p id="bind">
1537 <b class="header">bind</b><code>_.bind(function, object, *arguments)</code>
1538 <a href="docs/modules/bind.html" class="source">source</a>
1539 <br />
1540 Bind a <b>function</b> to an <b>object</b>, meaning that whenever
1541 the function is called, the value of <i>this</i> will be the <b>object</b>.
1542 Optionally, pass <b>arguments</b> to the <b>function</b> to pre-fill them,
1543 also known as <b>partial application</b>. For partial application without
1544 context binding, use <a href="#partial">partial</a>.
1545 </p>
1546 <pre>
1547 var func = function(greeting){ return greeting + ': ' + this.name };
1548 func = _.bind(func, {name: 'moe'}, 'hi');
1549 func();
1550 =&gt; 'hi: moe'
1551 </pre>
1552
1553 <p id="bindAll">
1554 <b class="header">bindAll</b><code>_.bindAll(object, *methodNames)</code>
1555 <a href="docs/modules/bindAll.html" class="source">source</a>
1556 <br />
1557 Binds a number of methods on the <b>object</b>, specified by
1558 <b>methodNames</b>, to be run in the context of that object whenever they
1559 are invoked. Very handy for binding functions that are going to be used
1560 as event handlers, which would otherwise be invoked with a fairly useless
1561 <i>this</i>. <b>methodNames</b> are required.
1562 </p>
1563 <pre>
1564 var buttonView = {
1565 label : 'underscore',
1566 onClick: function(){ alert('clicked: ' + this.label); },
1567 onHover: function(){ console.log('hovering: ' + this.label); }
1568 };
1569 _.bindAll(buttonView, 'onClick', 'onHover');
1570 // When the button is clicked, this.label will have the correct value.
1571 jQuery('#underscore_button').on('click', buttonView.onClick);
1572 </pre>
1573
1574 <p id="partial">
1575 <b class="header">partial</b><code>_.partial(function, *arguments)</code>
1576 <a href="docs/modules/partial.html" class="source">source</a>
1577 <br />
1578 Partially apply a function by filling in any number of its
1579 <b>arguments</b>, <i>without</i> changing its dynamic <tt>this</tt>
1580 value. A close cousin of <a href="#bind">bind</a>. You may pass
1581 <tt>_</tt> in your list of <b>arguments</b> to specify an argument that
1582 should not be pre-filled, but left open to supply at call-time.
1583 <i>Note: if you need <tt>_</tt> placeholders and a <tt>this</tt>
1584 binding at the same time, use both <tt>_.partial</tt> and
1585 <tt>_.bind</tt></i>.
1586 </p>
1587 <pre>
1588 var subtract = function(a, b) { return b - a; };
1589 sub5 = _.partial(subtract, 5);
1590 sub5(20);
1591 =&gt; 15
1592
1593 // Using a placeholder
1594 subFrom20 = _.partial(subtract, _, 20);
1595 subFrom20(5);
1596 =&gt; 15
1597 </pre>
1598
1599 <p id="memoize">
1600 <b class="header">memoize</b><code>_.memoize(function, [hashFunction])</code>
1601 <a href="docs/modules/memoize.html" class="source">source</a>
1602 <br />
1603 Memoizes a given <b>function</b> by caching the computed result. Useful
1604 for speeding up slow-running computations. If passed an optional
1605 <b>hashFunction</b>, it will be used to compute the hash key for storing
1606 the result, based on the arguments to the original function. The default
1607 <b>hashFunction</b> just uses the first argument to the memoized function
1608 as the key. The cache of memoized values is available as the <tt>cache</tt>
1609 property on the returned function.
1610 </p>
1611 <pre>
1612 var fibonacci = _.memoize(function(n) {
1613 return n &lt; 2 ? n: fibonacci(n - 1) + fibonacci(n - 2);
1614 });
1615 </pre>
1616
1617 <p id="delay">
1618 <b class="header">delay</b><code>_.delay(function, wait, *arguments)</code>
1619 <a href="docs/modules/delay.html" class="source">source</a>
1620 <br />
1621 Much like <b>setTimeout</b>, invokes <b>function</b> after <b>wait</b>
1622 milliseconds. If you pass the optional <b>arguments</b>, they will be
1623 forwarded on to the <b>function</b> when it is invoked.
1624 </p>
1625 <pre>
1626 var log = _.bind(console.log, console);
1627 _.delay(log, 1000, 'logged later');
1628 =&gt; 'logged later' // Appears after one second.
1629 </pre>
1630
1631 <p id="defer">
1632 <b class="header">defer</b><code>_.defer(function, *arguments)</code>
1633 <a href="docs/modules/defer.html" class="source">source</a>
1634 <br />
1635 Defers invoking the <b>function</b> until the current call stack has cleared,
1636 similar to using <b>setTimeout</b> with a delay of 0. Useful for performing
1637 expensive computations or HTML rendering in chunks without blocking the UI thread
1638 from updating. If you pass the optional <b>arguments</b>, they will be
1639 forwarded on to the <b>function</b> when it is invoked.
1640 </p>
1641 <pre>
1642 _.defer(function(){ alert('deferred'); });
1643 // Returns from the function before the alert runs.
1644 </pre>
1645
1646 <p id="throttle">
1647 <b class="header">throttle</b><code>_.throttle(function, wait, [options])</code>
1648 <a href="docs/modules/throttle.html" class="source">source</a>
1649 <br />
1650 Creates and returns a new, throttled version of the passed function,
1651 that, when invoked repeatedly, will only actually call the original function
1652 at most once per every <b>wait</b>
1653 milliseconds. Useful for rate-limiting events that occur faster than you
1654 can keep up with.
1655 </p>
1656 <p>
1657 By default, <b>throttle</b> will execute the function as soon as you call it
1658 for the first time, and, if you call it again any number of times
1659 during the <b>wait</b> period, as soon as that period is over.
1660 If you'd like to disable the leading-edge
1661 call, pass <tt>{leading: false}</tt>, and if you'd like to disable the
1662 execution on the trailing-edge, pass <br /> <tt>{trailing: false}</tt>.
1663 </p>
1664 <pre>
1665 var throttled = _.throttle(updatePosition, 100);
1666 $(window).scroll(throttled);
1667 </pre>
1668 <p>
1669 If you need to cancel a scheduled throttle, you can call <tt>.cancel()</tt>
1670 on the throttled function.
1671 </p>
1672
1673 <p id="debounce">
1674 <b class="header">debounce</b><code>_.debounce(function, wait, [immediate])</code>
1675 <a href="docs/modules/debounce.html" class="source">source</a>
1676 <br />
1677 Creates and returns a new debounced version of the passed function which
1678 will postpone its execution until after
1679 <b>wait</b> milliseconds have elapsed since the last time it
1680 was invoked. Useful for implementing behavior that should only happen
1681 <i>after</i> the input has stopped arriving. For example: rendering a
1682 preview of a Markdown comment, recalculating a layout after the window
1683 has stopped being resized, and so on.
1684 </p>
1685 <p>
1686 At the end of the <b>wait</b> interval, the function will be called
1687 with the arguments that were passed <i>most recently</i> to the
1688 debounced function.
1689 </p>
1690 <p>
1691 Pass <tt>true</tt> for the <b>immediate</b> argument to cause
1692 <b>debounce</b> to trigger the function on the leading instead of the
1693 trailing edge of the <b>wait</b> interval. Useful in circumstances like
1694 preventing accidental double-clicks on a "submit" button from firing a
1695 second time.
1696 </p>
1697 <pre>
1698 var lazyLayout = _.debounce(calculateLayout, 300);
1699 $(window).resize(lazyLayout);
1700 </pre>
1701 <p>
1702 If you need to cancel a scheduled debounce, you can call <tt>.cancel()</tt>
1703 on the debounced function.
1704 </p>
1705
1706 <p id="once">
1707 <b class="header">once</b><code>_.once(function)</code>
1708 <a href="docs/modules/once.html" class="source">source</a>
1709 <br />
1710 Creates a version of the function that can only be called one time.
1711 Repeated calls to the modified function will have no effect, returning
1712 the value from the original call. Useful for initialization functions,
1713 instead of having to set a boolean flag and then check it later.
1714 </p>
1715 <pre>
1716 var initialize = _.once(createApplication);
1717 initialize();
1718 initialize();
1719 // Application is only created once.
1720 </pre>
1721
1722 <p id="after">
1723 <b class="header">after</b><code>_.after(count, function)</code>
1724 <a href="docs/modules/after.html" class="source">source</a>
1725 <br />
1726 Creates a wrapper of <b>function</b> that does nothing at first. From
1727 the <b>count</b>-th call onwards, it starts actually calling
1728 <b>function</b>. Useful for grouping asynchronous responses, where you
1729 want to be sure that all the async calls have finished, before
1730 proceeding.
1731 </p>
1732 <pre>
1733 var renderNotes = _.after(notes.length, render);
1734 _.each(notes, function(note) {
1735 note.asyncSave({success: renderNotes});
1736 });
1737 // renderNotes is run once, after all notes have saved.
1738 </pre>
1739
1740 <p id="before">
1741 <b class="header">before</b><code>_.before(count, function)</code>
1742 <a href="docs/modules/before.html" class="source">source</a>
1743 <br />
1744 Creates a wrapper of <b>function</b> that memoizes its return value.
1745 From the <b>count</b>-th call onwards, the memoized result of the last
1746 invocation is returned immediately instead of invoking <b>function</b>
1747 again. So the wrapper will invoke <b>function</b> at most <b>count</b>
1748 - 1 times.
1749 </p>
1750 <pre>
1751 var monthlyMeeting = _.before(3, askForRaise);
1752 monthlyMeeting();
1753 monthlyMeeting();
1754 monthlyMeeting();
1755 // the result of any subsequent calls is the same as the second call
1756 </pre>
1757
1758 <p id="wrap">
1759 <b class="header">wrap</b><code>_.wrap(function, wrapper)</code>
1760 <a href="docs/modules/wrap.html" class="source">source</a>
1761 <br />
1762 Wraps the first <b>function</b> inside of the <b>wrapper</b> function,
1763 passing it as the first argument. This allows the <b>wrapper</b> to
1764 execute code before and after the <b>function</b> runs, adjust the arguments,
1765 and execute it conditionally.
1766 </p>
1767 <pre>
1768 var hello = function(name) { return "hello: " + name; };
1769 hello = _.wrap(hello, function(func) {
1770 return "before, " + func("moe") + ", after";
1771 });
1772 hello();
1773 =&gt; 'before, hello: moe, after'
1774 </pre>
1775
1776 <p id="negate">
1777 <b class="header">negate</b><code>_.negate(predicate)</code>
1778 <a href="docs/modules/negate.html" class="source">source</a>
1779 <br />
1780 Returns a new negated version of the <a href="#iteratee"><b>predicate</b></a> function.
1781 </p>
1782 <pre>
1783 var isFalsy = _.negate(Boolean);
1784 _.find([-2, -1, 0, 1, 2], isFalsy);
1785 =&gt; 0
1786 </pre>
1787
1788 <p id="compose">
1789 <b class="header">compose</b><code>_.compose(*functions)</code>
1790 <a href="docs/modules/compose.html" class="source">source</a>
1791 <br />
1792 Returns the composition of a list of <b>functions</b>, where each function
1793 consumes the return value of the function that follows. In math terms,
1794 composing the functions <i>f()</i>, <i>g()</i>, and <i>h()</i> produces
1795 <i>f(g(h()))</i>.
1796 </p>
1797 <pre>
1798 var greet = function(name){ return "hi: " + name; };
1799 var exclaim = function(statement){ return statement.toUpperCase() + "!"; };
1800 var welcome = _.compose(greet, exclaim);
1801 welcome('moe');
1802 =&gt; 'hi: MOE!'
1803 </pre>
1804
1805 <p id="restArguments">
1806 <b class="header">restArguments</b><code>_.restArguments(function, [startIndex])</code>
1807 <a href="docs/modules/restArguments.html" class="source">source</a>
1808 <br />
1809 Returns a version of the <b>function</b> that, when called, receives all
1810 arguments from and beyond <b>startIndex</b> collected into a single array.
1811 If you don’t pass an explicit <b>startIndex</b>, it will be determined by
1812 looking at the number of arguments to the <b>function</b> itself. Similar
1813 to ES6’s <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest
1814 parameters syntax</a>.
1815 </p>
1816 <pre>
1817 var raceResults = _.restArguments(function(gold, silver, bronze, everyoneElse) {
1818 _.each(everyoneElse, sendConsolations);
1819 });
1820
1821 raceResults("Dopey", "Grumpy", "Happy", "Sneezy", "Bashful", "Sleepy", "Doc");
1822 </pre>
1823
1824 <h2 id="objects">Object Functions</h2>
1825
1826 <p id="keys">
1827 <b class="header">keys</b><code>_.keys(object)</code>
1828 <a href="docs/modules/keys.html" class="source">source</a>
1829 <br />
1830 Retrieve all the names of the <b>object</b>'s own enumerable properties.
1831 </p>
1832 <pre>
1833 _.keys({one: 1, two: 2, three: 3});
1834 =&gt; ["one", "two", "three"]
1835 </pre>
1836
1837 <p id="allKeys">
1838 <b class="header">allKeys</b><code>_.allKeys(object)</code>
1839 <a href="docs/modules/allKeys.html" class="source">source</a>
1840 <br />
1841 Retrieve <i>all</i> the names of <b>object</b>'s own and inherited properties.
1842 </p>
1843 <pre>
1844 function Stooge(name) {
1845 this.name = name;
1846 }
1847 Stooge.prototype.silly = true;
1848 _.allKeys(new Stooge("Moe"));
1849 =&gt; ["name", "silly"]
1850 </pre>
1851
1852 <p id="values">
1853 <b class="header">values</b><code>_.values(object)</code>
1854 <a href="docs/modules/values.html" class="source">source</a>
1855 <br />
1856 Return all of the values of the <b>object</b>'s own properties.
1857 </p>
1858 <pre>
1859 _.values({one: 1, two: 2, three: 3});
1860 =&gt; [1, 2, 3]
1861 </pre>
1862
1863 <p id="mapObject">
1864 <b class="header">mapObject</b><code>_.mapObject(object, iteratee, [context])</code>
1865 <a href="docs/modules/mapObject.html" class="source">source</a>
1866 <br />
1867 Like <a href="#map">map</a>, but for objects. Transform the value
1868 of each property in turn.
1869 </p>
1870 <pre>
1871 _.mapObject({start: 5, end: 12}, function(val, key) {
1872 return val + 5;
1873 });
1874 =&gt; {start: 10, end: 17}
1875 </pre>
1876
1877 <p id="pairs">
1878 <b class="header">pairs</b><code>_.pairs(object)</code>
1879 <a href="docs/modules/pairs.html" class="source">source</a>
1880 <br />
1881 Convert an object into a list of <tt>[key, value]</tt> pairs. The opposite
1882 of <a href="#object">object</a>.
1883 </p>
1884 <pre>
1885 _.pairs({one: 1, two: 2, three: 3});
1886 =&gt; [["one", 1], ["two", 2], ["three", 3]]
1887 </pre>
1888
1889 <p id="invert">
1890 <b class="header">invert</b><code>_.invert(object)</code>
1891 <a href="docs/modules/invert.html" class="source">source</a>
1892 <br />
1893 Returns a copy of the <b>object</b> where the keys have become the values
1894 and the values the keys. For this to work, all of your object's values
1895 should be unique and string serializable.
1896 </p>
1897 <pre>
1898 _.invert({Moe: "Moses", Larry: "Louis", Curly: "Jerome"});
1899 =&gt; {Moses: "Moe", Louis: "Larry", Jerome: "Curly"};
1900 </pre>
1901
1902 <p id="create">
1903 <b class="header">create</b><code>_.create(prototype, props)</code>
1904 <a href="docs/modules/create.html" class="source">source</a>
1905 <br />
1906 Creates a new object with the given prototype, optionally attaching
1907 <b>props</b> as <i>own</i> properties. Basically, <tt>Object.create</tt>,
1908 but without all of the property descriptor jazz.
1909 </p>
1910 <pre>
1911 var moe = _.create(Stooge.prototype, {name: "Moe"});
1912 </pre>
1913
1914 <p id="object-functions">
1915 <b class="header">functions</b><code>_.functions(object)</code>
1916 <span class="alias">Alias: <b>methods</b></span>
1917 <a href="docs/modules/functions.html" class="source">source</a>
1918 <br />
1919 Returns a sorted list of the names of every method in an object &mdash;
1920 that is to say, the name of every function property of the object.
1921 </p>
1922 <pre>
1923 _.functions(_);
1924 =&gt; ["all", "any", "bind", "bindAll", "clone", "compact", "compose" ...
1925 </pre>
1926
1927 <p id="findKey">
1928 <b class="header">findKey</b><code>_.findKey(object, predicate, [context])</code>
1929 <a href="docs/modules/findKey.html" class="source">source</a>
1930 <br />
1931 Similar to <a href="#findIndex"><tt>_.findIndex</tt></a> but for keys in objects.
1932 Returns the <i>key</i> where the <b>predicate</b> truth test
1933 passes or <i>undefined</i>.
1934 <b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
1935 to facilitate shorthand syntaxes.
1936 </p>
1937
1938 <p id="extend">
1939 <b class="header">extend</b><code>_.extend(destination, *sources)</code>
1940 <a href="docs/modules/extend.html" class="source">source</a>
1941 <br />
1942 Shallowly copy all of the properties <strong>in</strong> the <b>source</b> objects over to the
1943 <b>destination</b> object, and return the <b>destination</b> object.
1944 Any nested objects or arrays will be copied by reference, not duplicated.
1945 It's in-order, so the last source will override properties of the same
1946 name in previous arguments.
1947 </p>
1948 <pre>
1949 _.extend({name: 'moe'}, {age: 50});
1950 =&gt; {name: 'moe', age: 50}
1951 </pre>
1952
1953 <p id="extendOwn">
1954 <b class="header">extendOwn</b><code>_.extendOwn(destination, *sources)</code>
1955 <span class="alias">Alias: <b>assign</b></span>
1956 <a href="docs/modules/extendOwn.html" class="source">source</a>
1957 <br />
1958 Like <b>extend</b>, but only copies <i>own</i> properties over to the
1959 destination object.
1960 </p>
1961
1962 <p id="pick">
1963 <b class="header">pick</b><code>_.pick(object, *keys)</code>
1964 <a href="docs/modules/pick.html" class="source">source</a>
1965 <br />
1966 Return a copy of the <b>object</b>, filtered to only have values for
1967 the allowed <b>keys</b> (or array of valid keys). Alternatively
1968 accepts a predicate indicating which keys to pick.
1969 </p>
1970 <pre>
1971 _.pick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age');
1972 =&gt; {name: 'moe', age: 50}
1973 _.pick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {
1974 return _.isNumber(value);
1975 });
1976 =&gt; {age: 50}
1977 </pre>
1978
1979 <p id="omit">
1980 <b class="header">omit</b><code>_.omit(object, *keys)</code>
1981 <a href="docs/modules/omit.html" class="source">source</a>
1982 <br />
1983 Return a copy of the <b>object</b>, filtered to omit the disallowed
1984 <b>keys</b> (or array of keys). Alternatively accepts a predicate
1985 indicating which keys to omit.
1986 </p>
1987 <pre>
1988 _.omit({name: 'moe', age: 50, userid: 'moe1'}, 'userid');
1989 =&gt; {name: 'moe', age: 50}
1990 _.omit({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {
1991 return _.isNumber(value);
1992 });
1993 =&gt; {name: 'moe', userid: 'moe1'}
1994 </pre>
1995
1996 <p id="defaults">
1997 <b class="header">defaults</b><code>_.defaults(object, *defaults)</code>
1998 <a href="docs/modules/defaults.html" class="source">source</a>
1999 <br />
2000 Returns <b>object</b> after filling in its <tt>undefined</tt> properties
2001 with the first value present in the following list of <b>defaults</b> objects.
2002 </p>
2003 <pre>
2004 var iceCream = {flavor: "chocolate"};
2005 _.defaults(iceCream, {flavor: "vanilla", sprinkles: "lots"});
2006 =&gt; {flavor: "chocolate", sprinkles: "lots"}
2007 </pre>
2008
2009 <p id="clone">
2010 <b class="header">clone</b><code>_.clone(object)</code>
2011 <a href="docs/modules/clone.html" class="source">source</a>
2012 <br />
2013 Create a shallow-copied clone of the provided <i>plain</i> <b>object</b>.
2014 Any nested objects or arrays will be copied by reference, not duplicated.
2015 </p>
2016 <pre>
2017 _.clone({name: 'moe'});
2018 =&gt; {name: 'moe'};
2019 </pre>
2020
2021 <p id="tap">
2022 <b class="header">tap</b><code>_.tap(object, interceptor)</code>
2023 <a href="docs/modules/tap.html" class="source">source</a>
2024 <br />
2025 Invokes <b>interceptor</b> with the <b>object</b>, and then returns <b>object</b>.
2026 The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
2027 </p>
2028 <pre>
2029 _.chain([1,2,3,200])
2030 .filter(function(num) { return num % 2 == 0; })
2031 .tap(alert)
2032 .map(function(num) { return num * num })
2033 .value();
2034 =&gt; // [2, 200] (alerted)
2035 =&gt; [4, 40000]
2036 </pre>
2037
2038 <p id="toPath">
2039 <b class="header">toPath</b><code>_.toPath(path)</code>
2040 <a href="docs/modules/toPath.html" class="source">source</a>
2041 <br>
2042 Ensures that <b>path</b> is an array. If <b>path</b> is a string, it is
2043 wrapped in a single-element array; if it is an array already, it is
2044 returned unmodified.
2045 </p>
2046 <pre>
2047 _.toPath('key');
2048 =&gt; ['key']
2049 _.toPath(['a', 0, 'b']);
2050 =&gt; ['a', 0, 'b'] // (same array)
2051 </pre>
2052 <p>
2053 <tt>_.toPath</tt> is used internally in <tt>has</tt>, <tt>get</tt>,
2054 <tt>invoke</tt>, <tt>property</tt>, <tt>propertyOf</tt> and
2055 <tt>result</tt>, as well as in <a href="#iteratee"><b>iteratee</b></a>
2056 and all functions that depend on it, in order to normalize deep
2057 property paths. You can override <tt>_.toPath</tt> if you want to
2058 customize this behavior, for example to enable Lodash-like string path
2059 shorthands. Be advised that altering <tt>_.toPath</tt> will unavoidably
2060 cause some keys to become unreachable; override at your own risk.
2061 </p>
2062 <pre>
2063 // Support dotted path shorthands.
2064 var originalToPath = _.toPath;
2065 _.mixin({
2066 toPath: function(path) {
2067 return _.isString(path) ? path.split('.') : originalToPath(path);
2068 }
2069 });
2070 _.get({a: [{b: 5}]}, 'a.0.b');
2071 =&gt; 5
2072 </pre>
2073
2074 <p id="get">
2075 <b class="header">get</b><code>_.get(object, path, [default])</code>
2076 <a href="docs/modules/get.html" class="source">source</a>
2077 <br>
2078 Returns the specified property of <b>object</b>. <b>path</b> may be
2079 specified as a simple key, or as an array of object keys or array
2080 indexes, for deep property fetching. If the property does not exist or
2081 is <tt>undefined</tt>, the optional <b>default</b> is returned.
2082 </p>
2083 <pre>
2084 _.get({a: 10}, 'a');
2085 =&gt; 10
2086 _.get({a: [{b: 2}]}, ['a', 0, 'b']);
2087 =&gt; 2
2088 _.get({a: 10}, 'b', 100);
2089 =&gt; 100
2090 </pre>
2091
2092 <p id="has">
2093 <b class="header">has</b><code>_.has(object, key)</code>
2094 <a href="docs/modules/has.html" class="source">source</a>
2095 <br />
2096 Does the object contain the given key? Identical to
2097 <tt>object.hasOwnProperty(key)</tt>, but uses a safe reference to the
2098 <tt>hasOwnProperty</tt> function, in case it's been
2099
2100 <a href="https://www.pixelstech.net/article/1326986170-An-Object-is-not-a-Hash">overridden accidentally</a>.
2101 </p>
2102 <pre>
2103 _.has({a: 1, b: 2, c: 3}, "b");
2104 =&gt; true
2105 </pre>
2106
2107 <p id="property">
2108 <b class="header">property</b><code>_.property(path)</code>
2109 <a href="docs/modules/property.html" class="source">source</a>
2110 <br />
2111 Returns a function that will return the specified property of any
2112 passed-in object. <tt>path</tt> may be specified as a simple key, or
2113 as an array of object keys or array indexes, for deep property fetching.
2114 </p>
2115 <pre>
2116 var stooge = {name: 'moe'};
2117 'moe' === _.property('name')(stooge);
2118 =&gt; true
2119
2120 var stooges = {moe: {fears: {worst: 'Spiders'}}, curly: {fears: {worst: 'Moe'}}};
2121 var curlysWorstFear = _.property(['curly', 'fears', 'worst']);
2122 curlysWorstFear(stooges);
2123 =&gt; 'Moe'
2124 </pre>
2125
2126 <p id="propertyOf">
2127 <b class="header">propertyOf</b><code>_.propertyOf(object)</code>
2128 <a href="docs/modules/propertyOf.html" class="source">source</a>
2129 <br />
2130 Inverse of <tt>_.property</tt>. Takes an object and returns a function
2131 which will return the value of a provided property.
2132 </p>
2133 <pre>
2134 var stooge = {name: 'moe'};
2135 _.propertyOf(stooge)('name');
2136 =&gt; 'moe'</pre>
2137
2138 <p id="matcher">
2139 <b class="header">matcher</b><code>_.matcher(attrs)</code>
2140 <span class="alias">Alias: <b>matches</b></span>
2141 <a href="docs/modules/matcher.html" class="source">source</a>
2142 <br />
2143 Returns a predicate function that will tell you if a passed in object
2144 contains all of the key/value properties present in <b>attrs</b>.
2145 </p>
2146 <pre>
2147 var ready = _.matcher({selected: true, visible: true});
2148 var readyToGoList = _.filter(list, ready);</pre>
2149
2150 <p id="isEqual">
2151 <b class="header">isEqual</b><code>_.isEqual(object, other)</code>
2152 <a href="docs/modules/isEqual.html" class="source">source</a>
2153 <br />
2154 Performs an optimized deep comparison between the two objects, to determine
2155 if they should be considered equal.
2156 </p>
2157 <pre>
2158 var stooge = {name: 'moe', luckyNumbers: [13, 27, 34]};
2159 var clone = {name: 'moe', luckyNumbers: [13, 27, 34]};
2160 stooge == clone;
2161 =&gt; false
2162 _.isEqual(stooge, clone);
2163 =&gt; true
2164 </pre>
2165
2166 <p id="isMatch">
2167 <b class="header">isMatch</b><code>_.isMatch(object, properties)</code>
2168 <a href="docs/modules/isMatch.html" class="source">source</a>
2169 <br />
2170 Tells you if the keys and values in <b>properties</b> are contained
2171 in <b>object</b>.
2172 </p>
2173 <pre>
2174 var stooge = {name: 'moe', age: 32};
2175 _.isMatch(stooge, {age: 32});
2176 =&gt; true
2177 </pre>
2178
2179 <p id="isEmpty">
2180 <b class="header">isEmpty</b><code>_.isEmpty(collection)</code>
2181 <a href="docs/modules/isEmpty.html" class="source">source</a>
2182 <br />
2183 Returns <i>true</i> if <b>collection</b> has no elements. For strings
2184 and array-like objects <tt>_.isEmpty</tt> checks if the length property
2185 is 0. For other objects, it returns <i>true</i> if the object has no
2186 enumerable own-properties. Note that primitive numbers, booleans and
2187 symbols are always empty by this definition.
2188 </p>
2189 <pre>
2190 _.isEmpty([1, 2, 3]);
2191 =&gt; false
2192 _.isEmpty({});
2193 =&gt; true
2194 </pre>
2195
2196 <p id="isElement">
2197 <b class="header">isElement</b><code>_.isElement(object)</code>
2198 <a href="docs/modules/isElement.html" class="source">source</a>
2199 <br />
2200 Returns <i>true</i> if <b>object</b> is a DOM element.
2201 </p>
2202 <pre>
2203 _.isElement(jQuery('body')[0]);
2204 =&gt; true
2205 </pre>
2206
2207 <p id="isArray">
2208 <b class="header">isArray</b><code>_.isArray(object)</code>
2209 <a href="docs/modules/isArray.html" class="source">source</a>
2210 <br />
2211 Returns <i>true</i> if <b>object</b> is an Array.
2212 </p>
2213 <pre>
2214 (function(){ return _.isArray(arguments); })();
2215 =&gt; false
2216 _.isArray([1,2,3]);
2217 =&gt; true
2218 </pre>
2219
2220 <p id="isObject">
2221 <b class="header">isObject</b><code>_.isObject(value)</code>
2222 <a href="docs/modules/isObject.html" class="source">source</a>
2223 <br />
2224 Returns <i>true</i> if <b>value</b> is an Object. Note that JavaScript
2225 arrays and functions are objects, while (normal) strings and numbers are not.
2226 </p>
2227 <pre>
2228 _.isObject({});
2229 =&gt; true
2230 _.isObject(1);
2231 =&gt; false
2232 </pre>
2233
2234 <p id="isArguments">
2235 <b class="header">isArguments</b><code>_.isArguments(object)</code>
2236 <a href="docs/modules/isArguments.html" class="source">source</a>
2237 <br />
2238 Returns <i>true</i> if <b>object</b> is an Arguments object.
2239 </p>
2240 <pre>
2241 (function(){ return _.isArguments(arguments); })(1, 2, 3);
2242 =&gt; true
2243 _.isArguments([1,2,3]);
2244 =&gt; false
2245 </pre>
2246
2247 <p id="isFunction">
2248 <b class="header">isFunction</b><code>_.isFunction(object)</code>
2249 <a href="docs/modules/isFunction.html" class="source">source</a>
2250 <br />
2251 Returns <i>true</i> if <b>object</b> is a Function.
2252 </p>
2253 <pre>
2254 _.isFunction(alert);
2255 =&gt; true
2256 </pre>
2257
2258 <p id="isString">
2259 <b class="header">isString</b><code>_.isString(object)</code>
2260 <a href="docs/modules/isString.html" class="source">source</a>
2261 <br />
2262 Returns <i>true</i> if <b>object</b> is a String.
2263 </p>
2264 <pre>
2265 _.isString("moe");
2266 =&gt; true
2267 </pre>
2268
2269 <p id="isNumber">
2270 <b class="header">isNumber</b><code>_.isNumber(object)</code>
2271 <a href="docs/modules/isNumber.html" class="source">source</a>
2272 <br />
2273 Returns <i>true</i> if <b>object</b> is a Number (including <tt>NaN</tt>).
2274 </p>
2275 <pre>
2276 _.isNumber(8.4 * 5);
2277 =&gt; true
2278 </pre>
2279
2280 <p id="isFinite">
2281 <b class="header">isFinite</b><code>_.isFinite(object)</code>
2282 <a href="docs/modules/isFinite.html" class="source">source</a>
2283 <br />
2284 Returns <i>true</i> if <b>object</b> is a finite Number.
2285 </p>
2286 <pre>
2287 _.isFinite(-101);
2288 =&gt; true
2289
2290 _.isFinite(-Infinity);
2291 =&gt; false
2292 </pre>
2293
2294 <p id="isBoolean">
2295 <b class="header">isBoolean</b><code>_.isBoolean(object)</code>
2296 <a href="docs/modules/isBoolean.html" class="source">source</a>
2297 <br />
2298 Returns <i>true</i> if <b>object</b> is either <i>true</i> or <i>false</i>.
2299 </p>
2300 <pre>
2301 _.isBoolean(null);
2302 =&gt; false
2303 </pre>
2304
2305 <p id="isDate">
2306 <b class="header">isDate</b><code>_.isDate(object)</code>
2307 <a href="docs/modules/isDate.html" class="source">source</a>
2308 <br />
2309 Returns <i>true</i> if <b>object</b> is a Date.
2310 </p>
2311 <pre>
2312 _.isDate(new Date());
2313 =&gt; true
2314 </pre>
2315
2316 <p id="isRegExp">
2317 <b class="header">isRegExp</b><code>_.isRegExp(object)</code>
2318 <a href="docs/modules/isRegExp.html" class="source">source</a>
2319 <br />
2320 Returns <i>true</i> if <b>object</b> is a RegExp.
2321 </p>
2322 <pre>
2323 _.isRegExp(/moe/);
2324 =&gt; true
2325 </pre>
2326
2327 <p id="isError">
2328 <b class="header">isError</b><code>_.isError(object)</code>
2329 <a href="docs/modules/isError.html" class="source">source</a>
2330 <br />
2331 Returns <i>true</i> if <b>object</b> inherits from an Error.
2332 </p>
2333 <pre>
2334 try {
2335 throw new TypeError("Example");
2336 } catch (o_O) {
2337 _.isError(o_O);
2338 }
2339 =&gt; true
2340 </pre>
2341
2342 <p id="isSymbol">
2343 <b class="header">isSymbol</b><code>_.isSymbol(object)</code>
2344 <a href="docs/modules/isSymbol.html" class="source">source</a>
2345 <br />
2346 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol">Symbol</a>.
2347 </p>
2348 <pre>
2349 _.isSymbol(Symbol());
2350 =&gt; true
2351 </pre>
2352
2353 <p id="isMap">
2354 <b class="header">isMap</b><code>_.isMap(object)</code>
2355 <a href="docs/modules/isMap.html" class="source">source</a>
2356 <br />
2357 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>.
2358 </p>
2359 <pre>
2360 _.isMap(new Map());
2361 =&gt; true
2362 </pre>
2363
2364 <p id="isWeakMap">
2365 <b class="header">isWeakMap</b><code>_.isWeakMap(object)</code>
2366 <a href="docs/modules/isWeakMap.html" class="source">source</a>
2367 <br />
2368 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap">WeakMap</a>.
2369 </p>
2370 <pre>
2371 _.isWeakMap(new WeakMap());
2372 =&gt; true
2373 </pre>
2374
2375 <p id="isSet">
2376 <b class="header">isSet</b><code>_.isSet(object)</code>
2377 <a href="docs/modules/isSet.html" class="source">source</a>
2378 <br />
2379 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set">Set</a>.
2380 </p>
2381 <pre>
2382 _.isSet(new Set());
2383 =&gt; true
2384 </pre>
2385
2386 <p id="isWeakSet">
2387 <b class="header">isWeakSet</b><code>_.isWeakSet(object)</code>
2388 <a href="docs/modules/isWeakSet.html" class="source">source</a>
2389 <br />
2390 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet">WeakSet</a>.
2391 </p>
2392 <pre>
2393 _.isWeakSet(WeakSet());
2394 =&gt; true
2395 </pre>
2396
2397 <p id="isArrayBuffer">
2398 <b class="header">isArrayBuffer</b><code>_.isArrayBuffer(object)</code>
2399 <a href="docs/modules/isArrayBuffer.html" class="source">source</a>
2400 <br />
2401 Returns <i>true</i> if <b>object</b> is an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>.
2402 </p>
2403 <pre>
2404 _.isArrayBuffer(new ArrayBuffer(8));
2405 =&gt; true
2406 </pre>
2407
2408 <p id="isDataView">
2409 <b class="header">isDataView</b><code>_.isDataView(object)</code>
2410 <a href="docs/modules/isDataView.html" class="source">source</a>
2411 <br />
2412 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView">DataView</a>.
2413 </p>
2414 <pre>
2415 _.isDataView(new DataView(new ArrayBuffer(8)));
2416 =&gt; true
2417 </pre>
2418
2419 <p id="isTypedArray">
2420 <b class="header">isTypedArray</b><code>_.isTypedArray(object)</code>
2421 <a href="docs/modules/isTypedArray.html" class="source">source</a>
2422 <br />
2423 Returns <i>true</i> if <b>object</b> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray">TypedArray</a>.
2424 </p>
2425 <pre>
2426 _.isTypedArray(new Int8Array(8));
2427 =&gt; true
2428 </pre>
2429
2430 <p id="isNaN">
2431 <b class="header">isNaN</b><code>_.isNaN(object)</code>
2432 <a href="docs/modules/isNaN.html" class="source">source</a>
2433 <br />
2434 Returns <i>true</i> if <b>object</b> is <i>NaN</i>.<br /> Note: this is not
2435 the same as the native <b>isNaN</b> function, which will also return
2436 true for many other not-number values, such as <tt>undefined</tt>.
2437 </p>
2438 <pre>
2439 _.isNaN(NaN);
2440 =&gt; true
2441 isNaN(undefined);
2442 =&gt; true
2443 _.isNaN(undefined);
2444 =&gt; false
2445 </pre>
2446
2447 <p id="isNull">
2448 <b class="header">isNull</b><code>_.isNull(object)</code>
2449 <a href="docs/modules/isNull.html" class="source">source</a>
2450 <br />
2451 Returns <i>true</i> if the value of <b>object</b> is <i>null</i>.
2452 </p>
2453 <pre>
2454 _.isNull(null);
2455 =&gt; true
2456 _.isNull(undefined);
2457 =&gt; false
2458 </pre>
2459
2460 <p id="isUndefined">
2461 <b class="header">isUndefined</b><code>_.isUndefined(value)</code>
2462 <a href="docs/modules/isUndefined.html" class="source">source</a>
2463 <br />
2464 Returns <i>true</i> if <b>value</b> is <i>undefined</i>.
2465 </p>
2466 <pre>
2467 _.isUndefined(window.missingVariable);
2468 =&gt; true
2469 </pre>
2470
2471 <h2 id="utility">Utility Functions</h2>
2472
2473 <p id="noConflict">
2474 <b class="header">noConflict</b><code>_.noConflict()</code>
2475 <a href="docs/modules/noConflict.html" class="source">source</a>
2476 <br />
2477 Give control of the global <tt>_</tt> variable back to its previous
2478 owner. Returns a reference to the <b>Underscore</b> object.
2479 </p>
2480 <pre>
2481 var underscore = _.noConflict();
2482 </pre>
2483 <p>
2484 The <tt>_.noConflict</tt> function is not present if you use the EcmaScript 6, AMD or CommonJS module system to import Underscore.
2485 </p>
2486
2487 <p id="identity">
2488 <b class="header">identity</b><code>_.identity(value)</code>
2489 <a href="docs/modules/identity.html" class="source">source</a>
2490 <br />
2491 Returns the same value that is used as the argument. In math:
2492 <tt>f(x) = x</tt><br />
2493 This function looks useless, but is used throughout Underscore as
2494 a default iteratee.
2495 </p>
2496 <pre>
2497 var stooge = {name: 'moe'};
2498 stooge === _.identity(stooge);
2499 =&gt; true
2500 </pre>
2501
2502 <p id="constant">
2503 <b class="header">constant</b><code>_.constant(value)</code>
2504 <a href="docs/modules/constant.html" class="source">source</a>
2505 <br />
2506 Creates a function that returns the same value that is used as the
2507 argument of <tt>_.constant</tt>.
2508 </p>
2509 <pre>
2510 var stooge = {name: 'moe'};
2511 stooge === _.constant(stooge)();
2512 =&gt; true</pre>
2513
2514 <p id="noop">
2515 <b class="header">noop</b><code>_.noop()</code>
2516 <a href="docs/modules/noop.html" class="source">source</a>
2517 <br />
2518 Returns <tt>undefined</tt> irrespective of the arguments passed to it.
2519 Useful as the default for optional callback arguments.
2520 </p>
2521 <pre>
2522 obj.initialize = _.noop;
2523 </pre>
2524
2525 <p id="times">
2526 <b class="header">times</b><code>_.times(n, iteratee, [context])</code>
2527 <a href="docs/modules/times.html" class="source">source</a>
2528 <br />
2529 Invokes the given iteratee function <b>n</b> times. Each invocation of
2530 <a href="#iteratee"><b>iteratee</b></a> is called with an <tt>index</tt> argument.
2531 Produces an array of the returned values.
2532 </p>
2533 <pre>
2534 _.times(3, function(n){ genie.grantWishNumber(n); });</pre>
2535
2536 <p id="random">
2537 <b class="header">random</b><code>_.random(min, max)</code>
2538 <a href="docs/modules/random.html" class="source">source</a>
2539 <br />
2540 Returns a random integer between <b>min</b> and <b>max</b>, inclusive.
2541 If you only pass one argument, it will return a number between <tt>0</tt>
2542 and that number.
2543 </p>
2544 <pre>
2545 _.random(0, 100);
2546 =&gt; 42</pre>
2547
2548 <p id="mixin">
2549 <b class="header">mixin</b><code>_.mixin(object)</code>
2550 <a href="docs/modules/mixin.html" class="source">source</a>
2551 <br />
2552 Allows you to extend Underscore with your own utility functions. Pass
2553 a hash of <tt>{name: function}</tt> definitions to have your functions
2554 added to the Underscore object, as well as the OOP wrapper. Returns the
2555 Underscore object to facilitate chaining.</p>
2556 <pre>
2557 _.mixin({
2558 capitalize: function(string) {
2559 return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
2560 }
2561 });
2562 _("fabio").capitalize();
2563 =&gt; "Fabio"
2564 </pre>
2565
2566 <p id="iteratee">
2567 <b class="header">iteratee</b><code>_.iteratee(value, [context])</code>
2568 <a href="docs/modules/iteratee.html" class="source">source</a>
2569 <br />
2570 Generates a callback that can be applied to each element in
2571 a collection. <tt>_.iteratee</tt> supports a number of shorthand
2572 syntaxes for common callback use cases. Depending upon <tt>value</tt>'s
2573 type, <tt>_.iteratee</tt> will return:
2574 </p>
2575 <pre>
2576 // No value
2577 _.iteratee();
2578 => _.identity()
2579
2580 // Function
2581 _.iteratee(function(n) { return n * 2; });
2582 => function(n) { return n * 2; }
2583
2584 // Object
2585 _.iteratee({firstName: 'Chelsea'});
2586 => _.matcher({firstName: 'Chelsea'});
2587
2588 // Anything else
2589 _.iteratee('firstName');
2590 => _.property('firstName');</pre>
2591
2592 <p>
2593 The following Underscore methods transform their predicates through
2594 <tt>_.iteratee</tt>: <tt>countBy</tt>, <tt>every</tt>,
2595 <tt>filter</tt>, <tt>find</tt>, <tt>findIndex</tt>, <tt>findKey</tt>,
2596 <tt>findLastIndex</tt>, <tt>groupBy</tt>, <tt>indexBy</tt>,
2597 <tt>map</tt>, <tt>mapObject</tt>, <tt>max</tt>, <tt>min</tt>,
2598 <tt>partition</tt>, <tt>reject</tt>, <tt>some</tt>, <tt>sortBy</tt>,
2599 <tt>sortedIndex</tt>, and <tt>uniq</tt>
2600 </p>
2601
2602 <p>
2603 You may overwrite <tt>_.iteratee</tt> with your own custom function,
2604 if you want additional or different shorthand syntaxes:
2605 </p>
2606 <pre>
2607 // Support `RegExp` predicate shorthand.
2608 var builtinIteratee = _.iteratee;
2609 _.iteratee = function(value, context) {
2610 if (_.isRegExp(value)) return function(obj) { return value.test(obj) };
2611 return builtinIteratee(value, context);
2612 };</pre>
2613 <p id="uniqueId">
2614 <b class="header">uniqueId</b><code>_.uniqueId([prefix])</code>
2615 <a href="docs/modules/uniqueId.html" class="source">source</a>
2616 <br />
2617 Generate a globally-unique id for client-side models or DOM elements
2618 that need one. If <b>prefix</b> is passed, the id will be appended to it.
2619 </p>
2620 <pre>
2621 _.uniqueId('contact_');
2622 =&gt; 'contact_104'</pre>
2623
2624 <p id="escape">
2625 <b class="header">escape</b><code>_.escape(string)</code>
2626 <a href="docs/modules/escape.html" class="source">source</a>
2627 <br />
2628 Escapes a string for insertion into HTML, replacing
2629 <tt>&amp;</tt>, <tt>&lt;</tt>, <tt>&gt;</tt>, <tt>&quot;</tt>, <tt>&#x60;</tt>, and <tt>&#x27;</tt> characters.
2630 </p>
2631 <pre>
2632 _.escape('Curly, Larry &amp; Moe');
2633 =&gt; "Curly, Larry &amp;amp; Moe"</pre>
2634
2635 <p id="unescape">
2636 <b class="header">unescape</b><code>_.unescape(string)</code>
2637 <a href="docs/modules/unescape.html" class="source">source</a>
2638 <br />
2639 The opposite of <a href="#escape"><b>escape</b></a>, replaces
2640 <tt>&amp;amp;</tt>, <tt>&amp;lt;</tt>, <tt>&amp;gt;</tt>,
2641 <tt>&amp;quot;</tt>, <tt>&amp;#x60;</tt> and <tt>&amp;#x27;</tt>
2642 with their unescaped counterparts.
2643 </p>
2644 <pre>
2645 _.unescape('Curly, Larry &amp;amp; Moe');
2646 =&gt; "Curly, Larry &amp; Moe"</pre>
2647
2648 <p id="result">
2649 <b class="header">result</b><code>_.result(object, property, [defaultValue])</code>
2650 <a href="docs/modules/result.html" class="source">source</a>
2651 <br />
2652 If the value of the named <b>property</b> is a function then invoke it
2653 with the <b>object</b> as context; otherwise, return it. If a default value
2654 is provided and the property doesn't exist or is undefined then the default
2655 will be returned. If <tt>defaultValue</tt> is a function its result will be returned.
2656 </p>
2657 <pre>
2658 var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }};
2659 _.result(object, 'cheese');
2660 =&gt; "crumpets"
2661 _.result(object, 'stuff');
2662 =&gt; "nonsense"
2663 _.result(object, 'meat', 'ham');
2664 =&gt; "ham"
2665 </pre>
2666
2667 <p id="now">
2668 <b class="header">now</b><code>_.now()</code>
2669 <a href="docs/modules/now.html" class="source">source</a>
2670 <br />
2671 Returns an integer timestamp for the current time, using the fastest
2672 method available in the runtime. Useful for implementing timing/animation
2673 functions.
2674 </p>
2675 <pre>
2676 _.now();
2677 =&gt; 1392066795351
2678 </pre>
2679
2680 <p id="template">
2681 <b class="header">template</b><code>_.template(templateString, [settings])</code>
2682 <a href="docs/modules/template.html" class="source">source</a>
2683 <br />
2684 Compiles JavaScript templates into functions that can be evaluated
2685 for rendering. Useful for rendering complicated bits of HTML from JSON
2686 data sources. Template functions can both interpolate values, using
2687 <tt>&lt;%= &hellip; %&gt;</tt>, as well as execute arbitrary JavaScript code, with
2688 <tt>&lt;% &hellip; %&gt;</tt>. If you wish to interpolate a value, and have
2689 it be HTML-escaped, use <tt>&lt;%- &hellip; %&gt;</tt>. When you evaluate a
2690 template function, pass in a <b>data</b> object that has properties
2691 corresponding to the template's free variables. The <b>settings</b> argument
2692 should be a hash containing any <tt>_.templateSettings</tt> that should be overridden.
2693 </p>
2694
2695 <pre>
2696 var compiled = _.template("hello: &lt;%= name %&gt;");
2697 compiled({name: 'moe'});
2698 =&gt; "hello: moe"
2699
2700 var template = _.template("&lt;b&gt;&lt;%- value %&gt;&lt;/b&gt;");
2701 template({value: '&lt;script&gt;'});
2702 =&gt; "&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;"</pre>
2703
2704 <p>
2705 You can also use <tt>print</tt> from within JavaScript code. This is
2706 sometimes more convenient than using <tt>&lt;%= ... %&gt;</tt>.
2707 </p>
2708
2709 <pre>
2710 var compiled = _.template("&lt;% print('Hello ' + epithet); %&gt;");
2711 compiled({epithet: "stooge"});
2712 =&gt; "Hello stooge"</pre>
2713
2714 <p>
2715 If ERB-style delimiters aren't your cup of tea, you can change Underscore's
2716 template settings to use different symbols to set off interpolated code.
2717 Define an <b>interpolate</b> regex to match expressions that should be
2718 interpolated verbatim, an <b>escape</b> regex to match expressions that should
2719 be inserted after being HTML-escaped, and an <b>evaluate</b> regex to match
2720 expressions that should be evaluated without insertion into the resulting
2721 string. Note that if part of your template matches more than one of these
2722 regexes, the first will be applied by the following order of priority:
2723 (1) <b>escape</b>, (2) <b>interpolate</b>, (3) <b>evaluate</b>. You may
2724 define or omit any combination of the three. For example, to perform
2725 <a href="https://github.com/janl/mustache.js#readme">Mustache.js</a>-style
2726 templating:
2727 </p>
2728
2729 <pre>
2730 _.templateSettings = {
2731 interpolate: /\{\{(.+?)\}\}/g
2732 };
2733
2734 var template = _.template("Hello {{ name }}!");
2735 template({name: "Mustache"});
2736 =&gt; "Hello Mustache!"</pre>
2737
2738 <p>
2739 By default, <b>template</b> places the values from your data in the local scope
2740 via the <tt>with</tt> statement. However, you can specify a single variable name
2741 with the <b>variable</b> setting. This can significantly improve the speed
2742 at which a template is able to render.
2743 </p>
2744
2745 <pre>
2746 _.template("Using 'with': <%= data.answer %>", {variable: 'data'})({answer: 'no'});
2747 =&gt; "Using 'with': no"</pre>
2748
2749 <p>
2750 Precompiling your templates can be a big help when debugging errors you can't
2751 reproduce. This is because precompiled templates can provide line numbers and
2752 a stack trace, something that is not possible when compiling templates on the client.
2753 The <b>source</b> property is available on the compiled template
2754 function for easy precompilation.
2755 </p>
2756
2757 <pre>&lt;script&gt;
2758 JST.project = <%= _.template(jstText).source %>;
2759 &lt;/script&gt;</pre>
2760
2761 <p id="version">
2762 <b class="header">VERSION</b>
2763 <br>
2764 It is possible to get the current Underscore version via
2765 <tt>_.VERSION</tt>
2766 .
2767 <pre>_.VERSION =&gt; 1.13.8</pre>
2768 </p>
2769
2770 <h2 id="oop">Object-Oriented Style</h2>
2771
2772 <p>
2773 You can use Underscore in either an object-oriented or a functional style,
2774 depending on your preference. The following two lines of code are
2775 identical ways to double a list of numbers.
2776 <a href="docs/modules/underscore.html" class="source">source</a>,
2777 <a href="docs/modules/mixin.html" class="source">source</a>
2778 </p>
2779
2780 <pre>
2781 _.map([1, 2, 3], function(n){ return n * 2; });
2782 _([1, 2, 3]).map(function(n){ return n * 2; });</pre>
2783
2784 <h2 id="chaining">Chaining</h2>
2785
2786 <p>
2787 Calling <tt>chain</tt> will cause all future method calls to return
2788 wrapped objects. When you've finished the computation, call
2789 <tt>value</tt> to retrieve the final value. Here's an example of chaining
2790 together a <b>map/flatten/reduce</b>, in order to get the word count of
2791 every word in a song.
2792 </p>
2793
2794 <pre>
2795 var lyrics = [
2796 {line: 1, words: "I'm a lumberjack and I'm okay"},
2797 {line: 2, words: "I sleep all night and I work all day"},
2798 {line: 3, words: "He's a lumberjack and he's okay"},
2799 {line: 4, words: "He sleeps all night and he works all day"}
2800 ];
2801
2802 _.chain(lyrics)
2803 .map(function(line) { return line.words.split(' '); })
2804 .flatten()
2805 .reduce(function(counts, word) {
2806 counts[word] = (counts[word] || 0) + 1;
2807 return counts;
2808 }, {})
2809 .value();
2810
2811 =&gt; {lumberjack: 2, all: 4, night: 2 ... }</pre>
2812
2813 <p>
2814 In addition, the
2815 <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/prototype">Array prototype's methods</a>
2816 are proxied through the chained Underscore object, so you can slip a
2817 <tt>reverse</tt> or a <tt>push</tt> into your chain, and continue to
2818 modify the array.
2819 </p>
2820
2821 <p id="chain">
2822 <b class="header">chain</b><code>_.chain(obj)</code>
2823 <a href="docs/modules/chain.html" class="source">source</a>
2824 <br />
2825 Returns a wrapped object. Calling methods on this object will continue
2826 to return wrapped objects until <tt>value</tt> is called.
2827 </p>
2828 <pre>
2829 var stooges = [{name: 'curly', age: 25}, {name: 'moe', age: 21}, {name: 'larry', age: 23}];
2830 var youngest = _.chain(stooges)
2831 .sortBy(function(stooge){ return stooge.age; })
2832 .map(function(stooge){ return stooge.name + ' is ' + stooge.age; })
2833 .first()
2834 .value();
2835 =&gt; "moe is 21"
2836 </pre>
2837
2838 <p id="value">
2839 <b class="header">value</b><code>_.chain(obj).value()</code>
2840 <a href="docs/modules/underscore.html" class="source">source</a>
2841 <br />
2842 Extracts the value of a wrapped object.
2843 </p>
2844 <pre>
2845 _.chain([1, 2, 3]).reverse().value();
2846 =&gt; [3, 2, 1]
2847 </pre>
2848
2849 <h2 id="links">Links &amp; Suggested Reading</h2>
2850
2851 <p>
2852 <a href="https://mirven.github.io/underscore.lua/">Underscore.lua</a>,
2853 a Lua port of the functions that are applicable in both languages.
2854 Includes OOP-wrapping and chaining.
2855 (<a href="https://github.com/mirven/underscore.lua">source</a>)
2856 </p>
2857
2858 <p>
2859 <a href="https://www.dollarswift.org/">Dollar.swift</a>, a Swift port
2860 of many of the Underscore.js functions and more.
2861 (<a href="https://github.com/ankurp/Dollar.swift">source</a>)
2862 </p>
2863
2864 <p>
2865 <a href="https://underscorem.org/">Underscore.m</a>, an Objective-C port
2866 of many of the Underscore.js functions, using a syntax that encourages
2867 chaining.
2868 (<a href="https://github.com/robb/Underscore.m">source</a>)
2869 </p>
2870
2871 <p>
2872 <a href="https://kmalakoff.github.io/_.m/">_.m</a>, an alternative
2873 Objective-C port that tries to stick a little closer to the original
2874 Underscore.js API.
2875 (<a href="https://github.com/kmalakoff/_.m">source</a>)
2876 </p>
2877
2878 <p>
2879 <a href="https://github.com/bdelespierre/underscore.php">Underscore.php</a>,
2880 a PHP port of the functions that are applicable in both languages.
2881 Tailored for PHP 5.4 and made with data-type tolerance in mind.
2882 (<a href="https://github.com/bdelespierre/underscore.php">source</a>)
2883 </p>
2884
2885 <p>
2886 <a href="https://vti.github.io/underscore-perl/">Underscore-perl</a>,
2887 a Perl port of many of the Underscore.js functions,
2888 aimed at on Perl hashes and arrays.
2889 (<a href="https://github.com/vti/underscore-perl">source</a>)
2890 </p>
2891
2892 <p>
2893 <a href="https://russplaysguitar.github.io/UnderscoreCF/">Underscore.cfc</a>,
2894 a Coldfusion port of many of the Underscore.js functions.
2895 (<a href="https://github.com/russplaysguitar/underscorecf">source</a>)
2896 </p>
2897
2898 <p>
2899 <a href="https://epeli.github.io/underscore.string/">Underscore.string</a>,
2900 an Underscore extension that adds functions for string-manipulation:
2901 <tt>trim</tt>, <tt>startsWith</tt>, <tt>contains</tt>, <tt>capitalize</tt>,
2902 <tt>reverse</tt>, <tt>sprintf</tt>, and more.
2903 </p>
2904
2905 <p>
2906 <a href="https://javadev.github.io/underscore-java/">Underscore-java</a>,
2907 a java port of the functions that are applicable in both languages.
2908 Includes OOP-wrapping and chaining.
2909 (<a href="https://github.com/javadev/underscore-java">source</a>)
2910 </p>
2911
2912 <p>
2913 Ruby's <a href="https://ruby-doc.org/core/classes/Enumerable.html">Enumerable</a> module.
2914 </p>
2915
2916 <p>
2917 <a href="https://prototypejs.org/">Prototype.js</a>, which provides
2918 JavaScript with collection functions in the manner closest to Ruby's Enumerable.
2919 </p>
2920
2921 <p>
2922 Oliver Steele's
2923 <a href="https://osteele.com/sources/javascript/functional/">Functional JavaScript</a>,
2924 which includes comprehensive higher-order function support as well as string lambdas.
2925 </p>
2926
2927 <p>
2928 Michael Aufreiter's <a href="https://github.com/substance/data">Data.js</a>,
2929 a data manipulation + persistence library for JavaScript.
2930 </p>
2931
2932 <p>
2933 Python's <a href="https://docs.python.org/library/itertools.html">itertools</a>.
2934 </p>
2935
2936 <p>
2937 <a href="https://toolz.readthedocs.org/">PyToolz</a>, a Python port
2938 that extends itertools and functools to include much of the
2939 Underscore API.
2940 </p>
2941
2942 <p>
2943 <a href="https://github.com/Suor/funcy">Funcy</a>, a practical
2944 collection of functional helpers for Python, partially inspired by Underscore.
2945 </p>
2946
2947 <h2 id="notes">Notes</h2>
2948
2949 <p id="relational-operator-note">
2950 <b class="header">On the use of <tt>&lt;</tt> in Underscore</b>
2951 <br>
2952 Underscore functions that depend on ordering, such as
2953 <a href="#sortBy"><tt>_.sortBy</tt></a> and
2954 <a href="#sortedIndex"><tt>_.sortedIndex</tt></a>, use
2955 JavaScript&rsquo;s built-in
2956 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Relational_operators">relational operators</a>,
2957 specifically the &ldquo;less than&rdquo; operator <tt>&lt;</tt>. It is
2958 important to understand that these operators are only meaningful for
2959 numbers and strings. You can throw any value to them, but JavaScript
2960 will convert the operands to string or number first before performing
2961 the actual comparison. If you pass an operand that
2962 cannot be meaningfully converted to string or number, it ends up being
2963 <tt>NaN</tt> by default. This value is unsortable.
2964 </p>
2965 <p>
2966 Ideally, the values that you are sorting should either be all
2967 (meaningfully convertible to) strings or all (meaningfully convertible
2968 to) numbers. If this is not the case, you have two options:
2969 <ul>
2970 <li>
2971 <a href="#filter"><tt>_.filter</tt></a> out all unsortable values
2972 first.
2973 </li>
2974 <li>
2975 Pick a target type, i.e., either string or number, and pass an
2976 <a href="#iteratee"><tt>iteratee</tt></a> to your Underscore
2977 function that will convert its argument to a sensible instance of
2978 the target type. For example, if you have an array of numbers that
2979 you want to sort and that may occasionally contain <tt>null</tt> or
2980 <tt>undefined</tt>, you can control whether you want to sort these
2981 before or after all numbers by passing an <tt>iteratee</tt> to
2982 <tt>_.sortBy</tt> that returns <tt>-Infinity</tt> or
2983 <tt>+Infinity</tt> for such values, respectively. Or maybe you want
2984 to treat them as zeros; it is up to you. The same <tt>iteratee</tt>
2985 can also be passed to other Underscore functions to ensure that the
2986 behavior is consistent.
2987 </li>
2988 </ul>
2989 </p>
2990
2991 <h2 id="changelog">Change Log</h2>
2992
2993 <p id="1.13.8">
2994 <b class="header">1.13.8</b> &mdash; <small><i>February 19, 2026</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.7...1.13.8">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.8/index.html">Docs</a><br />
2995 <ul>
2996 <li>
2997 Fixes a security issue in <tt>_.flatten</tt> and <tt>_.isEqual</tt>
2998 that, under very specific circumstances, could allow for a Denial of
2999 Service (DoS) attack in server applications. This bug was present in
3000 all previous versions of Underscore. More details: <a href="https://github.com/jashkenas/underscore/security/advisories/GHSA-qpx9-hpmf-5gmw">CVE-2026-27601</a>.
3001 </li>
3002 <li>
3003 Adds documentation for <tt>_.VERSION</tt>.
3004 </li>
3005 <li>
3006 Clarifies some terminology in the documentation for contributors.
3007 </li>
3008 </ul>
3009 </p>
3010
3011 <p id="1.13.7">
3012 <b class="header">1.13.7</b> &mdash; <small><i>July 24, 2024</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.6...1.13.7">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.7/index.html">Docs</a><br />
3013 <ul>
3014 <li>
3015 Fixes a bug where Underscore might throw an error on load if the
3016 executing environment overrides the native <tt>DataView</tt>.
3017 </li>
3018 <li>
3019 Adds a direct link to the corresponding source code for each
3020 function in the documentation.
3021 </li>
3022 <li>
3023 Clarifies the documentation for the <b>step</b> argument of
3024 the <tt>range</tt> function.
3025 </li>
3026 <li>
3027 Adds dark mode support to the home page.
3028 </li>
3029 <li>
3030 Other infrastructural improvements to funding, testing and building.
3031 </li>
3032 </ul>
3033 </p>
3034
3035 <p id="1.13.6">
3036 <b class="header">1.13.6</b> &mdash; <small><i>September 24, 2022</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.5...1.13.6">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.6/index.html">Docs</a><br />
3037 Hotfix for version 1.13.5 to remove a <tt>postinstall</tt> script from
3038 the package.json, which unexpectedly broke many people's builds.
3039 </p>
3040
3041 <p id="1.13.5">
3042 <b class="header">1.13.5</b> &mdash; <small><i>September 23, 2022</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.4...1.13.5">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.5/index.html">Docs</a><br />
3043 <ul>
3044 <li>
3045 Adds a <tt>module</tt> sub-entry to the package.json&rsquo;s <tt>exports.require</tt> condition. When a bundling tool, such as Rollup with recent versions of <tt>@rollup/plugin-node-resolve</tt>, takes the exports map very literally, this should prevent situations in which the final bundle includes multiple copies of Underscore in different module formats.
3046 </li>
3047 <li>
3048 Updates to the testing infrastructure and development dependencies.
3049 </li>
3050 <li>
3051 No code changes.
3052 </li>
3053 </ul>
3054 </p>
3055
3056 <p id="1.13.4">
3057 <b class="header">1.13.4</b> &mdash; <small><i>June 2, 2022</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.3...1.13.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.4/index.html">Docs</a><br />
3058 <ul>
3059 <li>
3060 Fixes a compatibility issue with WebPack module federation.
3061 </li>
3062 <li>
3063 Documentation improvements.
3064 </li>
3065 </ul>
3066 </p>
3067
3068 <p id="1.13.3">
3069 <b class="header">1.13.3</b> &mdash; <small><i>April 23, 2022</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.2...1.13.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.3/index.html">Docs</a><br />
3070 <ul>
3071 <li>
3072 Fixes a compatibility issue with ExtendScript.
3073 </li>
3074 <li>
3075 Various improvements to testing and continuous integration,
3076 including the addition of security scanning and a reduced carbon
3077 footprint.
3078 </li>
3079 </ul>
3080 </p>
3081
3082 <p id="1.13.2">
3083 <b class="header">1.13.2</b> &mdash; <small><i>December 16, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.1...1.13.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.2/index.html">Docs</a><br />
3084 <ul>
3085 <li>
3086 Fixes a regression introduced in 1.9.0 that caused
3087 <tt>_.sample</tt> and <tt>_.shuffle</tt> to no longer work on
3088 strings.
3089 </li>
3090 <li>
3091 Fixes an issue in IE8 compatibility code.
3092 </li>
3093 <li>
3094 Makes the website mobile-friendly.
3095 </li>
3096 <li>
3097 Various other minor documentation enhancements and a new test.
3098 </li>
3099 </ul>
3100 </p>
3101
3102 <p id="1.13.1">
3103 <b class="header">1.13.1</b> &mdash; <small><i>April 15, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0...1.13.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.1/index.html">Docs</a><br />
3104 <ul>
3105 <li>
3106 Restores the <tt>underscore.js</tt> alias committed to the GitHub
3107 repository.
3108 </li>
3109 <li>
3110 Adds some build clarifications to the documentation.
3111 </li>
3112 <li>
3113 No code changes.
3114 </li>
3115 </ul>
3116 </p>
3117
3118 <p id="1.13.0">
3119 <b class="header">1.13.0</b> &mdash; <small><i>April 9, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-3...1.13.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.0/index.html">Docs</a><br />
3120 <ul>
3121 <li>
3122 Merges the changes from the 1.13.0-0 through 1.13.0-3 preview
3123 releases into the main release stream following version 1.12.1. As
3124 of this release, ESM support is 100%.
3125 </li>
3126 <li>
3127 Adds a <a
3128 href="https://github.com/jashkenas/underscore/security/policy"
3129 >security policy</a> to the documentation.
3130 </li>
3131 <li>
3132 Adds funding information to the documentation.
3133 </li>
3134 </ul>
3135 </p>
3136
3137 <p id="1.13.0-3">
3138 <b class="header">1.13.0-3</b> &mdash; <small><i>March 31, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-2...1.13.0-3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.0-3/index.html">Docs</a><br />
3139 <ul>
3140 <li>
3141 Adds a <tt>"module"</tt> exports condition to the
3142 <tt>package.json</tt>, which should theoretically help to avoid
3143 duplicate code bundling with <tt>exports</tt>-aware build tools.
3144 </li>
3145 <li>
3146 Re-synchronizes some comments and documentation text with the
3147 1.12.x branch.
3148 </li>
3149 </ul>
3150 </p>
3151
3152 <p id="1.13.0-2">
3153 <b class="header">1.13.0-2</b> &mdash; <small><i>March 15, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-1...1.13.0-2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.0-2/index.html">Docs</a><br />
3154 <ul>
3155 <li>
3156 Fixes the same security issue in <tt>_.template</tt> as the
3157 parallel 1.12.1 release.
3158 </li>
3159 </ul>
3160 </p>
3161
3162 <p id="1.12.1">
3163 <b class="header">1.12.1</b> &mdash; <small><i>March 15, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.12.0...1.12.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.12.1/index.html">Docs</a><br />
3164 <ul>
3165 <li>
3166 Fixes a security issue in <tt>_.template</tt> that could enable a
3167 third party to inject code in compiled templates. This issue
3168 affects all versions of Underscore between 1.3.2 and 1.12.0,
3169 inclusive, as well as preview releases 1.13.0-0 and 1.13.0-1. The
3170 fix in this release is also included in the parallel preview
3171 release 1.13.0-2. <a
3172 href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23358"
3173 >CVE-2021-23358</a>
3174 </li>
3175 <li>
3176 Restores an optimization in <tt>_.debounce</tt> that was
3177 unintentionally lost in version 1.9.0 (same as in parallel preview
3178 release 1.13.0-0).
3179 </li>
3180 <li>
3181 Various test and documentation enhancements (same as in parallel
3182 preview releases 1.13.0-0 and 1.13.0-1).
3183 </li>
3184 </ul>
3185 </p>
3186
3187 <p id="1.13.0-1">
3188 <b class="header">1.13.0-1</b> &mdash; <small><i>March 11, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-0...1.13.0-1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.0-1/index.html">Docs</a><br />
3189 <ul>
3190 <li>
3191 Fixes an issue that caused aliases to be absent among the named
3192 exports in the new native ESM entry point for Node.js 12+.
3193 </li>
3194 <li>
3195 More test and documentation fixes and enhancements.
3196 </li>
3197 </ul>
3198 </p>
3199
3200 <p id="1.13.0-0">
3201 <b class="header">1.13.0-0</b> &mdash; <small><i>March 9, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.12.0...1.13.0-0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.0-0/index.html">Docs</a><br />
3202 <ul>
3203 <li>
3204 Adds experimental support for native ESM imports in Node.js. You
3205 can now also do named imports or even deep module imports directly
3206 from a Node.js process in Node.js version 12 and later. Monolithic
3207 imports are recommended for use in production. State (such as
3208 mixed-in functions) is shared between CommonJS and ESM consumers.
3209 </li>
3210 <li>
3211 Renames the UMD bundle to <tt>underscore-umd.js</tt> for
3212 consistency with the other bundle names. An alias named
3213 <tt>underscore.js</tt> is retained for backwards compatibility.
3214 </li>
3215 <li>
3216 Restores an optimization in <tt>_.debounce</tt> that was
3217 unintentionally lost in version 1.9.0.
3218 </li>
3219 <li>
3220 Various test and documentation enhancements.
3221 </li>
3222 </ul>
3223 </p>
3224
3225 <p id="1.12.0">
3226 <b class="header">1.12.0</b> &mdash; <small><i>November 24, 2020</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.11.0...1.12.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.12.0/index.html">Docs</a><br />
3227 <ul>
3228 <li>
3229 Adds the <tt>_.get</tt> and <tt>_.toPath</tt> functions. The latter
3230 can be overridden in order to customize the interpretation of deep
3231 property paths throughout Underscore. A future version of
3232 Underscore-contrib will be providing a ready-made function for this
3233 purpose; users will be able to opt in to string-based path
3234 shorthands such as <tt>'a.0.b'</tt> and <tt>'a[0]["b"]'</tt> by
3235 using that function from Underscore-contrib to override
3236 <tt>_.toPath</tt>.
3237 </li>
3238 <li>
3239 Fixes a bug in <tt>_.isEqual</tt> that caused typed arrays to
3240 compare equal when viewing different segments of the same
3241 underlying <tt>ArrayBuffer</tt>.
3242 </li>
3243 <li>
3244 Improves the compatibility of <tt>_.isEqual</tt>,
3245 <tt>_.isDataView</tt>, <tt>_.isMap</tt>, <tt>_.isWeakMap</tt> and
3246 <tt>_.isSet</tt> with some older browsers, especially IE 11.
3247 </li>
3248 <li>
3249 Significantly enhances the performance of <tt>_.isEmpty</tt> and
3250 several members of the isType family of functions.
3251 </li>
3252 <li>
3253 Speeds up <tt>_.isEqual</tt> comparison of typed arrays and
3254 <tt>DataView</tt>s with idential <tt>buffer</tt>,
3255 <tt>byteOffset</tt> and <tt>byteLength</tt>.
3256 </li>
3257 <li>
3258 Restores cross-browser testing during continuous integration to its
3259 former glory and adds documentation about engine compatibility.
3260 </li>
3261 <li>
3262 Slims down the development dependencies for testing.
3263 </li>
3264 </ul>
3265 </p>
3266
3267 <p id="1.11.0">
3268 <b class="header">1.11.0</b> &mdash; <small><i>August 28, 2020</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.10.2...1.11.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.11.0/index.html">Docs</a> &mdash; <a href="https://juliangonggrijp.com/article/introducing-modular-underscore.html">Article</a><br />
3269 <ul>
3270 <li>
3271 Puts the source of every function in a separate module, following
3272 up on the move to EcmaScript 6 <tt>export</tt> notation in <a
3273 href="#1.10.0">version 1.10.0</a>. AMD and CommonJS versions of the
3274 function modules are provided as well. This brings perfect
3275 treeshaking to all users and unlocks the possibility to create
3276 arbitrary custom Underscore builds without code size overhead.
3277 <tt>modules/index.js</tt> is still present and the UMD bundle is
3278 still recommended for most users.<br>
3279 Since the modularization obfuscates the diff, piecewise diffs are provided below.
3280 <ul>
3281 <li><a href="https://github.com/jashkenas/underscore/compare/1.10.2...3236023">
3282 Changes before modularization
3283 </a></li>
3284 <li><a href="https://github.com/jashkenas/underscore/compare/3236023...240d60a">
3285 Modularization itself
3286 </a></li>
3287 <li><a href="https://github.com/jashkenas/underscore/compare/240d60a...1.11.0">
3288 Changes after modularization
3289 </a></li>
3290 </ul>
3291 </li>
3292 <li>
3293 Adds a monolithic bundle in EcmaScript 6 module format,
3294 <tt>underscore-esm.js</tt>, as a modern alternative to the
3295 monolithic UMD bundle. Users who want to use ES module imports in
3296 the browser are advised to use this new bundle instead of
3297 <tt>modules/index.js</tt>, because <tt>underscore-esm.js</tt>
3298 provides the complete Underscore interface in a single download.
3299 </li>
3300 <li>
3301 Adds a modular version of the annotated source, reflecting the full
3302 internal structure of the primary source code.
3303 </li>
3304 <li>
3305 Adds <tt>_.isArrayBuffer</tt>, <tt>_.isDataView</tt> and
3306 <tt>_.isTypedArray</tt> functions, as well as support for the
3307 corresponding value types to <tt>_.isEqual</tt>.
3308 </li>
3309 <li>
3310 Adds the option to flatten arrays to a specific depth:
3311 <tt>_.flatten(anArray, 3)</tt>.
3312 </li>
3313 <li>
3314 Adds <tt>_.transpose</tt> as an alias to <tt>_.unzip</tt>.
3315 </li>
3316 <li>
3317 Fixes an inconsistency where <tt>Array.prototype</tt> methods on
3318 the Underscore wrapper would error when the wrapped value is
3319 <tt>null</tt> or <tt>undefined</tt>. These methods now perform a
3320 no-op on null values like the other Underscore functions.
3321 </li>
3322 <li>
3323 Fixes a bug that caused <tt>_.first</tt> and <tt>_.last</tt> to
3324 return <tt>[]</tt> instead of <tt>undefined</tt> for empty arrays
3325 when used as an iteratee.
3326 </li>
3327 <li>
3328 Fixes a regression introduced in version 1.9.0 that caused
3329 <tt>_.bindAll</tt> to return <tt>undefined</tt> instead of the
3330 bound object.
3331 </li>
3332 <li>
3333 Restores continuous integration testing with Travis CI.
3334 </li>
3335 <li>
3336 Replaces stigmatizing
3337 &ldquo;whitelist&rdquo;/&ldquo;blacklist&rdquo; terminology in
3338 comments and documentation by neutral
3339 &ldquo;allowed&rdquo;/&ldquo;disallowed&rdquo; terminology.
3340 </li>
3341 <li>
3342 Various clarifications and minor enhancements and fixes to the
3343 documentation, source comments and a test.
3344 </li>
3345 </ul>
3346 </p>
3347
3348 <p id="1.10.2">
3349 <b class="header">1.10.2</b> &mdash; <small><i>March 30, 2020</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.10.1...1.10.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.10.2/index.html">Docs</a><br />
3350 <ul>
3351 <li>
3352 Fixes a bug introduced with <tt>1.10.0</tt>, while using the legacy
3353 Node.js require API: <tt>var _ = require("underscore")._</tt>
3354 </li>
3355 </ul>
3356 </p>
3357
3358 <p id="1.10.1">
3359 <b class="header">1.10.1</b> &mdash; <small><i>March 30, 2020</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.10.0...1.10.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.10.1/index.html">Docs</a><br />
3360 <ul>
3361 <li>
3362 Fixed relative links among the ES Modules to include the file
3363 extension, for web browser support.
3364 </li>
3365 </ul>
3366 </p>
3367
3368 <p id="1.10.0">
3369 <b class="header">1.10.0</b> &mdash; <small><i>March 30, 2020</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.9.2...1.10.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.10.0/index.html">Docs</a><br />
3370 <ul>
3371 <li>
3372 Reformats the source code to use EcmaScript 6 <tt>export</tt>
3373 notation. The <tt>underscore.js</tt> UMD bundle is now <i>compiled
3374 from</i> underlying source modules instead of <i>being</i> the
3375 source. From now on, Rollup users have the option to import from
3376 the underlying source module in order to enable treeshaking.
3377 </li>
3378 <li>
3379 Explicitly states in the documentation, and verifies in the
3380 unittests, that <tt>_.sortedIndex(array, value)</tt> always returns
3381 the lower bound, i.e., the smallest index, at which <tt>value</tt>
3382 may be inserted in <tt>array</tt>.
3383 </li>
3384 <li>
3385 Makes the notation of the <tt>_.max</tt> unittest consistent with
3386 other unittests.
3387 </li>
3388 <li>
3389 Fixes a bug that would cause infinite recursion if an overridden
3390 implementation of <tt>_.iteratee</tt> attempted to fall back to the
3391 original implementation.
3392 </li>
3393 <li>
3394 Restores compatibility with EcmaScript 3 and ExtendScript.
3395 </li>
3396 </ul>
3397 </p>
3398
3399 <p id="1.9.2">
3400 <b class="header">1.9.2</b> &mdash; <small><i>Jan 6, 2020</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.9.1...1.9.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.9.2/index.html">Docs</a><br />
3401 <ul>
3402 <li>
3403 No code changes. Updated a test to help out
3404 <a href="https://github.com/nodejs/node/pull/31167#issuecomment-571022478">CITGM</a>.
3405 </li>
3406 </ul>
3407 </p>
3408
3409 <p id="1.9.1">
3410 <b class="header">1.9.1</b> &mdash; <small><i>May 31, 2018</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.9.0...1.9.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.9.1/index.html">Docs</a><br />
3411 <ul>
3412 <li>
3413 Fixes edge-case regressions from 1.9.0, including certain forms
3414 of calling <tt>_.first</tt> and <tt>_.last</tt> on an empty array,
3415 and passing arrays as keys to <tt>_.countBy</tt> and <tt>_.groupBy</tt>.
3416 </li>
3417 </ul>
3418 </p>
3419
3420 <p id="1.9.0">
3421 <b class="header">1.9.0</b> &mdash; <small><i>April 18, 2018</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.3...1.9.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.9.0/index.html">Docs</a><br />
3422 <ul>
3423 <li>
3424 Adds the <tt>_.restArguments</tt> function for variadic function
3425 handling.
3426 </li>
3427 <li>
3428 Adds the <tt>_.chunk</tt> function for chunking up an array.
3429 </li>
3430 <li>
3431 Adds a <tt>_.isSymbol</tt>, <tt>_.isMap</tt>, <tt>_.isWeakMap</tt>,
3432 <tt>_.isSet</tt> and <tt>_.isWeakSet</tt> functions.
3433 </li>
3434 <li>
3435 <tt>_.throttle</tt> and <tt>_.debounce</tt> return functions that now
3436 have a <tt>.cancel()</tt> method, which can be used to cancel any
3437 scheduled calls.
3438 </li>
3439 <li>
3440 <tt>_.property</tt> now accepts arrays of keys and indexes as path
3441 specifiers, for looking up a deep properties of a value.
3442 </li>
3443 <li>
3444 <tt>_.range</tt> now accepts negative ranges to generate descending
3445 arrays.
3446 </li>
3447 <li>
3448 Adds support for several environments including: WebWorkers,
3449 browserify and ES6 imports.
3450 </li>
3451 <li>
3452 Removes the <tt>component.json</tt> as the Component package
3453 management system is discontinued.
3454 </li>
3455 <li>
3456 The placeholder used for partial is now configurable by setting
3457 <code>_.partial.placeholder</code>.
3458 </li>
3459 <li>
3460 <code>_.bindAll</code> now accepts arrays or arguments for keys.
3461 </li>
3462 <li>
3463 Three years of performance improvements.
3464 </li>
3465 </ul>
3466 </p>
3467
3468 <p id="1.8.3">
3469 <b class="header">1.8.3</b> &mdash; <small><i>April 2, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.2...1.8.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.8.3/index.html">Docs</a><br />
3470 <ul>
3471 <li>
3472 Adds an <tt>_.create</tt> method, as a slimmed down version of
3473 <tt>Object.create</tt>.
3474 </li>
3475 <li>
3476 Works around an iOS bug that can improperly cause <tt>isArrayLike</tt>
3477 to be JIT-ed. Also fixes a bug when passing <tt>0</tt> to <tt>isArrayLike</tt>.
3478 </li>
3479 </ul>
3480 </p>
3481
3482 <p id="1.8.2">
3483 <b class="header">1.8.2</b> &mdash; <small><i>Feb. 22, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.1...1.8.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.8.2/index.html">Docs</a><br />
3484 <ul>
3485 <li>
3486 Restores the previous old-Internet-Explorer edge cases changed in
3487 1.8.1.
3488 </li>
3489 <li>
3490 Adds a <tt>fromIndex</tt> argument to <tt>_.contains</tt>.
3491 </li>
3492 </ul>
3493 </p>
3494
3495 <p id="1.8.1">
3496 <b class="header">1.8.1</b> &mdash; <small><i>Feb. 19, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.8.0...1.8.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.8.1/index.html">Docs</a><br />
3497 <ul>
3498 <li>
3499 Fixes/changes some old-Internet Explorer and related edge case
3500 behavior. Test your app with Underscore 1.8.1 in an old IE and let
3501 us know how it's doing...
3502 </li>
3503 </ul>
3504 </p>
3505
3506 <p id="1.8.0">
3507 <b class="header">1.8.0</b> &mdash; <small><i>Feb. 19, 2015</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.7.0...1.8.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.8.0/index.html">Docs</a><br />
3508 <ul>
3509 <li>
3510 Added <tt>_.mapObject</tt>, which is similar to <tt>_.map</tt>, but just
3511 for the values in your object. (A real crowd pleaser.)
3512 </li>
3513 <li>
3514 Added <tt>_.allKeys</tt> which returns <i>all</i> the enumerable property
3515 names on an object.
3516 </li>
3517 <li>
3518 Reverted a 1.7.0 change where <tt>_.extend</tt> only copied "own"
3519 properties. Hopefully this will un-break you &mdash; if it breaks you
3520 again, I apologize.
3521 </li>
3522 <li>
3523 Added <tt>_.extendOwn</tt> &mdash; a less-useful form of <tt>_.extend</tt> that
3524 only copies over "own" properties.
3525 </li>
3526 <li>
3527 Added <tt>_.findIndex</tt> and <tt>_.findLastIndex</tt> functions,
3528 which nicely complement their twin-twins <tt>_.indexOf</tt> and <tt>_.lastIndexOf</tt>.
3529 </li>
3530 <li>
3531 Added an <tt>_.isMatch</tt> predicate function that tells you if an
3532 object matches key-value properties. A kissing cousin of
3533 <tt>_.isEqual</tt> and <tt>_.matcher</tt>.
3534 </li>
3535 <li>
3536 Added an <tt>_.isError</tt> function.
3537 </li>
3538 <li>
3539 Restored the <tt>_.unzip</tt> function as the inverse of <tt>zip</tt>.
3540 Flip-flopping. I know.
3541 </li>
3542 <li>
3543 <tt>_.result</tt> now takes an optional fallback value (or function
3544 that provides the fallback value).
3545 </li>
3546 <li>
3547 Added the <tt>_.propertyOf</tt> function generator as a mirror-world
3548 version of <tt>_.property</tt>.
3549 </li>
3550 <li>
3551 Deprecated <tt>_.matches</tt>. It's now known by a more harmonious
3552 name — <tt>_.matcher</tt>.
3553 </li>
3554 <li>
3555 Various and diverse code simplifications, changes for improved
3556 cross-platform compatibility, and edge case bug fixes.
3557 </li>
3558 </ul>
3559 </p>
3560
3561 <p id="1.7.0">
3562 <b class="header">1.7.0</b> &mdash; <small><i>August 26, 2014</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.6.0...1.7.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.7.0/index.html">Docs</a><br />
3563 <ul>
3564 <li>
3565 For consistency and speed across browsers, Underscore now ignores
3566 native array methods for <tt>forEach</tt>, <tt>map</tt>, <tt>reduce</tt>,
3567 <tt>reduceRight</tt>, <tt>filter</tt>, <tt>every</tt>, <tt>some</tt>,
3568 <tt>indexOf</tt>, and <tt>lastIndexOf</tt>. "Sparse" arrays are
3569 officially dead in Underscore.
3570 </li>
3571 <li>
3572 Added <tt>_.iteratee</tt> to customize the iterators used by collection
3573 functions. Many Underscore methods will take a string argument for easier
3574 <tt>_.property</tt>-style lookups, an object for <tt>_.where</tt>-style
3575 filtering, or a function as a custom callback.
3576 </li>
3577 <li>
3578 Added <tt>_.before</tt> as a counterpart to <tt>_.after</tt>.
3579 </li>
3580 <li>
3581 Added <tt>_.negate</tt> to invert the truth value of a passed-in
3582 predicate.
3583 </li>
3584 <li>
3585 Added <tt>_.noop</tt> as a handy empty placeholder function.
3586 </li>
3587 <li>
3588 <tt>_.isEmpty</tt> now works with <tt>arguments</tt> objects.
3589 </li>
3590 <li>
3591 <tt>_.has</tt> now guards against nullish objects.
3592 </li>
3593 <li>
3594 <tt>_.omit</tt> can now take an iteratee function.
3595 </li>
3596 <li>
3597 <tt>_.partition</tt> is now called with <tt>index</tt> and <tt>object</tt>.
3598 </li>
3599 <li>
3600 <tt>_.matches</tt> creates a shallow clone of your object and only iterates
3601 over own properties.
3602 </li>
3603 <li>
3604 Aligning better with the forthcoming ECMA6 <tt>Object.assign</tt>,
3605 <tt>_.extend</tt> only iterates over the object's own properties.
3606 </li>
3607 <li>
3608 Falsy guards are no longer needed in <tt>_.extend</tt> and
3609 <tt>_.defaults</tt>&mdash;if the passed in argument isn't a JavaScript
3610 object it's just returned.
3611 </li>
3612 <li>
3613 Fixed a few edge cases in <tt>_.max</tt> and <tt>_.min</tt> to
3614 handle arrays containing <tt>NaN</tt> (like strings or other objects)
3615 and <tt>Infinity</tt> and <tt>-Infinity</tt>.
3616 </li>
3617 <li>
3618 Override base methods like <tt>each</tt> and <tt>some</tt>
3619 and they'll be used internally by other Underscore functions too.
3620 </li>
3621 <li>
3622 The escape functions handle backticks (<tt>`</tt>), to deal with an
3623 IE &le; 8 bug.
3624 </li>
3625 <li>
3626 For consistency, <tt>_.union</tt> and <tt>_.difference</tt> now
3627 only work with arrays and not variadic args.
3628 </li>
3629 <li>
3630 <tt>_.memoize</tt> exposes the cache of memoized values as a property
3631 on the returned function.
3632 </li>
3633 <li>
3634 <tt>_.pick</tt> accepts <tt>iteratee</tt> and <tt>context</tt>
3635 arguments for a more advanced callback.
3636 </li>
3637 <li>
3638 Underscore templates no longer accept an initial <tt>data</tt> object.
3639 <tt>_.template</tt> always returns a function now.
3640 </li>
3641 <li>
3642 Optimizations and code cleanup aplenty.
3643 </li>
3644 </ul>
3645 </p>
3646
3647 <p id="1.6.0">
3648 <b class="header">1.6.0</b> &mdash; <small><i>February 10, 2014</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.2...1.6.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.6.0/index.html">Docs</a><br />
3649 <ul>
3650 <li>
3651 Underscore now registers itself for AMD (Require.js), Bower and Component,
3652 as well as being a CommonJS module and a regular (Java)Script.
3653 An ugliness, but perhaps a necessary one.
3654 </li>
3655 <li>
3656 Added <tt>_.partition</tt>, a way to split a collection into two lists
3657 of results — those that pass and those that fail a particular predicate.
3658 </li>
3659 <li>
3660 Added <tt>_.property</tt>, for easy creation of iterators that pull
3661 specific properties from objects. Useful in conjunction with other
3662 Underscore collection functions.
3663 </li>
3664 <li>
3665 Added <tt>_.matches</tt>, a function that will give you a predicate
3666 that can be used to tell if a given object matches a list of specified
3667 key/value properties.
3668 </li>
3669 <li>
3670 Added <tt>_.constant</tt>, as a higher-order <tt>_.identity</tt>.
3671 </li>
3672 <li>
3673 Added <tt>_.now</tt>, an optimized way to get a timestamp &mdash; used
3674 internally to speed up <tt>debounce</tt> and <tt>throttle</tt>.
3675 </li>
3676 <li>
3677 The <tt>_.partial</tt> function may now be used to partially apply
3678 any of its arguments, by passing <tt>_</tt> wherever you'd like a
3679 placeholder variable, to be filled-in later.
3680 </li>
3681 <li>
3682 The <tt>_.each</tt> function now returns a reference to the list for chaining.
3683 </li>
3684 <li>
3685 The <tt>_.keys</tt> function now returns an empty array for
3686 non-objects instead of throwing.
3687 </li>
3688 <li>
3689 &hellip; and more miscellaneous refactoring.
3690 </li>
3691 </ul>
3692 </p>
3693
3694 <p id="1.5.2">
3695 <b class="header">1.5.2</b> &mdash; <small><i>September 7, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.1...1.5.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.5.2/index.html">Docs</a><br />
3696 <ul>
3697 <li>
3698 Added an <tt>indexBy</tt> function, which fits in alongside its
3699 cousins, <tt>countBy</tt> and <tt>groupBy</tt>.
3700 </li>
3701 <li>
3702 Added a <tt>sample</tt> function, for sampling random elements from
3703 arrays.
3704 </li>
3705 <li>
3706 Some optimizations relating to functions that can be implemented
3707 in terms of <tt>_.keys</tt> (which includes, significantly,
3708 <tt>each</tt> on objects). Also for <tt>debounce</tt> in a tight loop.
3709 </li>
3710 <li>
3711 The <tt>_.escape</tt> function no longer escapes '/'.
3712 </li>
3713 </ul>
3714 </p>
3715
3716 <p id="1.5.1">
3717 <b class="header">1.5.1</b> &mdash; <small><i>July 8, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.0...1.5.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.5.1/index.html">Docs</a><br />
3718 <ul>
3719 <li>
3720 Removed <tt>unzip</tt>, as it's simply the application of <tt>zip</tt>
3721 to an array of arguments. Use <tt>_.zip.apply(_, list)</tt> to
3722 transpose instead.
3723 </li>
3724 </ul>
3725 </p>
3726
3727 <p id="1.5.0">
3728 <b class="header">1.5.0</b> &mdash; <small><i>July 6, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.4...1.5.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.5.0/index.html">Docs</a><br />
3729 <ul>
3730 <li>
3731 Added a new <tt>unzip</tt> function, as the inverse of <tt>_.zip</tt>.
3732 </li>
3733 <li>
3734 The <tt>throttle</tt> function now takes an <tt>options</tt> argument,
3735 allowing you to disable execution of the throttled function on either
3736 the <b>leading</b> or <b>trailing</b> edge.
3737 </li>
3738 <li>
3739 A source map is now supplied for easier debugging of the minified
3740 production build of Underscore.
3741 </li>
3742 <li>
3743 The <tt>defaults</tt> function now only overrides <tt>undefined</tt>
3744 values, not <tt>null</tt> ones.
3745 </li>
3746 <li>
3747 Removed the ability to call <tt>_.bindAll</tt> with no method name
3748 arguments. It's pretty much always wiser to allow the names of
3749 the methods you'd like to bind.
3750 </li>
3751 <li>
3752 Removed the ability to call <tt>_.after</tt> with an invocation count
3753 of zero. The minimum number of calls is (naturally) now <tt>1</tt>.
3754 </li>
3755 </ul>
3756 </p>
3757
3758 <p id="1.4.4">
3759 <b class="header">1.4.4</b> &mdash; <small><i>January 30, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.3...1.4.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.4.4/index.html">Docs</a><br />
3760 <ul>
3761 <li>
3762 Added <tt>_.findWhere</tt>, for finding the first element in a list
3763 that matches a particular set of keys and values.
3764 </li>
3765 <li>
3766 Added <tt>_.partial</tt>, for partially applying a function <i>without</i>
3767 changing its dynamic reference to <tt>this</tt>.
3768 </li>
3769 <li>
3770 Simplified <tt>bind</tt> by removing some edge cases involving
3771 constructor functions. In short: don't <tt>_.bind</tt> your
3772 constructors.
3773 </li>
3774 <li>
3775 A minor optimization to <tt>invoke</tt>.
3776 </li>
3777 <li>
3778 Fix bug in the minified version due to the minifier incorrectly
3779 optimizing-away <tt>isFunction</tt>.
3780 </li>
3781 </ul>
3782 </p>
3783
3784 <p id="1.4.3">
3785 <b class="header">1.4.3</b> &mdash; <small><i>December 4, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.2...1.4.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.4.3/index.html">Docs</a><br />
3786 <ul>
3787 <li>
3788 Improved Underscore compatibility with Adobe's JS engine that can be
3789 used to script Illustrator, Photoshop, and friends.
3790 </li>
3791 <li>
3792 Added a default <tt>_.identity</tt> iterator to <tt>countBy</tt> and
3793 <tt>groupBy</tt>.
3794 </li>
3795 <li>
3796 The <tt>uniq</tt> function can now take <tt>array, iterator, context</tt>
3797 as the argument list.
3798 </li>
3799 <li>
3800 The <tt>times</tt> function now returns the mapped array of iterator
3801 results.
3802 </li>
3803 <li>
3804 Simplified and fixed bugs in <tt>throttle</tt>.
3805 </li>
3806 </ul>
3807 </p>
3808
3809 <p id="1.4.2">
3810 <b class="header">1.4.2</b> &mdash; <small><i>October 6, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.1...1.4.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.4.2/index.html">Docs</a><br />
3811 <ul>
3812 <li>
3813 For backwards compatibility, returned to pre-1.4.0 behavior when
3814 passing <tt>null</tt> to iteration functions. They now become no-ops
3815 again.
3816 </li>
3817 </ul>
3818 </p>
3819
3820 <p id="1.4.1">
3821 <b class="header">1.4.1</b> &mdash; <small><i>October 1, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.0...1.4.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.4.1/index.html">Docs</a><br />
3822 <ul>
3823 <li>
3824 Fixed a 1.4.0 regression in the <tt>lastIndexOf</tt> function.
3825 </li>
3826 </ul>
3827 </p>
3828
3829 <p id="1.4.0">
3830 <b class="header">1.4.0</b> &mdash; <small><i>September 27, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.3.3...1.4.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.4.0/index.html">Docs</a><br />
3831 <ul>
3832 <li>
3833 Added a <tt>pairs</tt> function, for turning a JavaScript object
3834 into <tt>[key, value]</tt> pairs ... as well as an <tt>object</tt>
3835 function, for converting an array of <tt>[key, value]</tt> pairs
3836 into an object.
3837 </li>
3838 <li>
3839 Added a <tt>countBy</tt> function, for counting the number of objects
3840 in a list that match a certain criteria.
3841 </li>
3842 <li>
3843 Added an <tt>invert</tt> function, for performing a simple inversion
3844 of the keys and values in an object.
3845 </li>
3846 <li>
3847 Added a <tt>where</tt> function, for easy cases of filtering a list
3848 for objects with specific values.
3849 </li>
3850 <li>
3851 Added an <tt>omit</tt> function, for filtering an object to remove
3852 certain keys.
3853 </li>
3854 <li>
3855 Added a <tt>random</tt> function, to return a random number in a
3856 given range.
3857 </li>
3858 <li>
3859 <tt>_.debounce</tt>'d functions now return their last updated value,
3860 just like <tt>_.throttle</tt>'d functions do.
3861 </li>
3862 <li>
3863 The <tt>sortBy</tt> function now runs a stable sort algorithm.
3864 </li>
3865 <li>
3866 Added the optional <tt>fromIndex</tt> option to <tt>indexOf</tt> and
3867 <tt>lastIndexOf</tt>.
3868 </li>
3869 <li>
3870 "Sparse" arrays are no longer supported in Underscore iteration
3871 functions. Use a <tt>for</tt> loop instead (or better yet, an object).
3872 </li>
3873 <li>
3874 The <tt>min</tt> and <tt>max</tt> functions may now be called on
3875 <i>very</i> large arrays.
3876 </li>
3877 <li>
3878 Interpolation in templates now represents <tt>null</tt> and
3879 <tt>undefined</tt> as the empty string.
3880 </li>
3881 <li>
3882 <del>Underscore iteration functions no longer accept <tt>null</tt> values
3883 as a no-op argument. You'll get an early error instead.</del>
3884 </li>
3885 <li>
3886 A number of edge-cases fixes and tweaks, which you can spot in the
3887 <a href="https://github.com/jashkenas/underscore/compare/1.3.3...1.4.0">diff</a>.
3888 Depending on how you're using Underscore, <b>1.4.0</b> may be more
3889 backwards-incompatible than usual &mdash; please test when you upgrade.
3890 </li>
3891 </ul>
3892 </p>
3893
3894 <p id="1.3.3">
3895 <b class="header">1.3.3</b> &mdash; <small><i>April 10, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.3.1...1.3.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.3.3/index.html">Docs</a><br />
3896 <ul>
3897 <li>
3898 Many improvements to <tt>_.template</tt>, which now provides the
3899 <tt>source</tt> of the template function as a property, for potentially
3900 even more efficient pre-compilation on the server-side. You may now
3901 also set the <tt>variable</tt> option when creating a template,
3902 which will cause your passed-in data to be made available under the
3903 variable you named, instead of using a <tt>with</tt> statement &mdash;
3904 significantly improving the speed of rendering the template.
3905 </li>
3906 <li>
3907 Added the <tt>pick</tt> function, which allows you to filter an
3908 object literal with a list of allowed property names.
3909 </li>
3910 <li>
3911 Added the <tt>result</tt> function, for convenience when working
3912 with APIs that allow either functions or raw properties.
3913 </li>
3914 <li>
3915 Added the <tt>isFinite</tt> function, because sometimes knowing that
3916 a value is a number just ain't quite enough.
3917 </li>
3918 <li>
3919 The <tt>sortBy</tt> function may now also be passed the string name
3920 of a property to use as the sort order on each object.
3921 </li>
3922 <li>
3923 Fixed <tt>uniq</tt> to work with sparse arrays.
3924 </li>
3925 <li>
3926 The <tt>difference</tt> function now performs a shallow flatten
3927 instead of a deep one when computing array differences.
3928 </li>
3929 <li>
3930 The <tt>debounce</tt> function now takes an <tt>immediate</tt>
3931 parameter, which will cause the callback to fire on the leading
3932 instead of the trailing edge.
3933 </li>
3934 </ul>
3935 </p>
3936
3937 <p id="1.3.1">
3938 <b class="header">1.3.1</b> &mdash; <small><i>January 23, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.3.0...1.3.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.3.1/index.html">Docs</a><br />
3939 <ul>
3940 <li>
3941 Added an <tt>_.has</tt> function, as a safer way to use <tt>hasOwnProperty</tt>.
3942 </li>
3943 <li>
3944 Added <tt>_.collect</tt> as an alias for <tt>_.map</tt>. Smalltalkers, rejoice.
3945 </li>
3946 <li>
3947 Reverted an old change so that <tt>_.extend</tt> will correctly copy
3948 over keys with undefined values again.
3949 </li>
3950 <li>
3951 Bugfix to stop escaping slashes within interpolations in <tt>_.template</tt>.
3952 </li>
3953 </ul>
3954 </p>
3955
3956 <p id="1.3.0">
3957 <b class="header">1.3.0</b> &mdash; <small><i>January 11, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.4...1.3.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.3.0/index.html">Docs</a><br />
3958 <ul>
3959 <li>
3960 Removed AMD (RequireJS) support from Underscore. If you'd like to use
3961 Underscore with RequireJS, you can load it as a normal script, wrap
3962 or patch your copy, or download a forked version.
3963 </li>
3964 </ul>
3965 </p>
3966
3967 <p id="1.2.4">
3968 <b class="header">1.2.4</b> &mdash; <small><i>January 4, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.3...1.2.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.2.4/index.html">Docs</a><br />
3969 <ul>
3970 <li>
3971 You now can (and probably should, as it's simpler)
3972 write <tt>_.chain(list)</tt>
3973 instead of <tt>_(list).chain()</tt>.
3974 </li>
3975 <li>
3976 Fix for escaped characters in Underscore templates, and for supporting
3977 customizations of <tt>_.templateSettings</tt> that only define one or
3978 two of the required regexes.
3979 </li>
3980 <li>
3981 Fix for passing an array as the first argument to an <tt>_.wrap</tt>'d function.
3982 </li>
3983 <li>
3984 Improved compatibility with ClojureScript, which adds a <tt>call</tt>
3985 function to <tt>String.prototype</tt>.
3986 </li>
3987 </ul>
3988 </p>
3989
3990 <p id="1.2.3">
3991 <b class="header">1.2.3</b> &mdash; <small><i>December 7, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.2...1.2.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.2.3/index.html">Docs</a><br />
3992 <ul>
3993 <li>
3994 Dynamic scope is now preserved for compiled <tt>_.template</tt> functions,
3995 so you can use the value of <tt>this</tt> if you like.
3996 </li>
3997 <li>
3998 Sparse array support of <tt>_.indexOf</tt>, <tt>_.lastIndexOf</tt>.
3999 </li>
4000 <li>
4001 Both <tt>_.reduce</tt> and <tt>_.reduceRight</tt> can now be passed an
4002 explicitly <tt>undefined</tt> value. (There's no reason why you'd
4003 want to do this.)
4004 </li>
4005 </ul>
4006 </p>
4007
4008 <p id="1.2.2">
4009 <b class="header">1.2.2</b> &mdash; <small><i>November 14, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.1...1.2.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.2.1/index.html">Docs</a><br />
4010 <ul>
4011 <li>
4012 Continued tweaks to <tt>_.isEqual</tt> semantics. Now JS primitives are
4013 considered equivalent to their wrapped versions, and arrays are compared
4014 by their numeric properties only <small>(#351)</small>.
4015 </li>
4016 <li>
4017 <tt>_.escape</tt> no longer tries to be smart about not double-escaping
4018 already-escaped HTML entities. Now it just escapes regardless <small>(#350)</small>.
4019 </li>
4020 <li>
4021 In <tt>_.template</tt>, you may now leave semicolons out of evaluated
4022 statements if you wish: <tt>&lt;% }) %&gt;</tt> <small>(#369)</small>.
4023 </li>
4024 <li>
4025 <tt>_.after(callback, 0)</tt> will now trigger the callback immediately,
4026 making "after" easier to use with asynchronous APIs <small>(#366)</small>.
4027 </li>
4028 </ul>
4029 </p>
4030
4031 <p id="1.2.1">
4032 <b class="header">1.2.1</b> &mdash; <small><i>October 24, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.0...1.2.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.2.1/index.html">Docs</a><br />
4033 <ul>
4034 <li>
4035 Several important bug fixes for <tt>_.isEqual</tt>, which should now
4036 do better on mutated Arrays, and on non-Array objects with
4037 <tt>length</tt> properties. <small>(#329)</small>
4038 </li>
4039 <li>
4040 <a href="https://github.com/jrburke">James Burke</a>
4041 contributed Underscore exporting for AMD module loaders, and
4042 <a href="https://github.com/tonylukasavage">Tony Lukasavage</a>
4043 for Appcelerator Titanium.
4044 <small>(#335, #338)</small>
4045 </li>
4046 <li>
4047 You can now <tt>_.groupBy(list, 'property')</tt> as a shortcut for
4048 grouping values by a particular common property.
4049 </li>
4050 <li>
4051 <tt>_.throttle</tt>'d functions now fire immediately upon invocation,
4052 and are rate-limited thereafter <small>(#170, #266)</small>.
4053 </li>
4054 <li>
4055 Most of the <tt>_.is[Type]</tt> checks no longer ducktype.
4056 </li>
4057 <li>
4058 The <tt>_.bind</tt> function now also works on constructors, a-la
4059 ES5 ... but you would never want to use <tt>_.bind</tt> on a
4060 constructor function.
4061 </li>
4062 <li>
4063 <tt>_.clone</tt> no longer wraps non-object types in Objects.
4064 </li>
4065 <li>
4066 <tt>_.find</tt> and <tt>_.filter</tt> are now the preferred names for
4067 <tt>_.detect</tt> and <tt>_.select</tt>.
4068 </li>
4069 </ul>
4070 </p>
4071
4072 <p id="1.2.0">
4073 <b class="header">1.2.0</b> &mdash; <small><i>October 5, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.7...1.2.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.2.0/index.html">Docs</a><br />
4074 <ul>
4075 <li>
4076 The <tt>_.isEqual</tt> function now
4077 supports true deep equality comparisons, with checks for cyclic structures,
4078 thanks to Kit Cambridge.
4079 </li>
4080 <li>
4081 Underscore templates now support HTML escaping interpolations, using
4082 <tt>&lt;%- ... %&gt;</tt> syntax.
4083 </li>
4084 <li>
4085 Ryan Tenney contributed <tt>_.shuffle</tt>, which uses a modified
4086 Fisher-Yates to give you a shuffled copy of an array.
4087 </li>
4088 <li>
4089 <tt>_.uniq</tt> can now be passed an optional iterator, to determine by
4090 what criteria an object should be considered unique.
4091 </li>
4092 <li>
4093 <tt>_.last</tt> now takes an optional argument which will return the last
4094 N elements of the list.
4095 </li>
4096 <li>
4097 A new <tt>_.initial</tt> function was added, as a mirror of <tt>_.rest</tt>,
4098 which returns all the initial values of a list (except the last N).
4099 </li>
4100 </ul>
4101 </p>
4102
4103 <p id="1.1.7">
4104 <b class="header">1.1.7</b> &mdash; <small><i>July 13, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.6...1.1.7">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.7/index.html">Docs</a><br />
4105 Added <tt>_.groupBy</tt>, which aggregates a collection into groups of like items.
4106 Added <tt>_.union</tt> and <tt>_.difference</tt>, to complement the
4107 (re-named) <tt>_.intersection</tt>.
4108 Various improvements for support of sparse arrays.
4109 <tt>_.toArray</tt> now returns a clone, if directly passed an array.
4110 <tt>_.functions</tt> now also returns the names of functions that are present
4111 in the prototype chain.
4112 </p>
4113
4114 <p id="1.1.6">
4115 <b class="header">1.1.6</b> &mdash; <small><i>April 18, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.5...1.1.6">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.6/index.html">Docs</a><br />
4116 Added <tt>_.after</tt>, which will return a function that only runs after
4117 first being called a specified number of times.
4118 <tt>_.invoke</tt> can now take a direct function reference.
4119 <tt>_.every</tt> now requires an iterator function to be passed, which
4120 mirrors the ES5 API.
4121 <tt>_.extend</tt> no longer copies keys when the value is undefined.
4122 <tt>_.bind</tt> now errors when trying to bind an undefined value.
4123 </p>
4124
4125 <p id="1.1.5">
4126 <b class="header">1.1.5</b> &mdash; <small><i>March 20, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.4...1.1.5">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.5/index.html">Docs</a><br />
4127 Added an <tt>_.defaults</tt> function, for use merging together JS objects
4128 representing default options.
4129 Added an <tt>_.once</tt> function, for manufacturing functions that should
4130 only ever execute a single time.
4131 <tt>_.bind</tt> now delegates to the native ES5 version,
4132 where available.
4133 <tt>_.keys</tt> now throws an error when used on non-Object values, as in
4134 ES5.
4135 Fixed a bug with <tt>_.keys</tt> when used over sparse arrays.
4136 </p>
4137
4138 <p id="1.1.4">
4139 <b class="header">1.1.4</b> &mdash; <small><i>January 9, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.3...1.1.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.4/index.html">Docs</a><br />
4140 Improved compliance with ES5's Array methods when passing <tt>null</tt>
4141 as a value. <tt>_.wrap</tt> now correctly sets <tt>this</tt> for the
4142 wrapped function. <tt>_.indexOf</tt> now takes an optional flag for
4143 finding the insertion index in an array that is guaranteed to already
4144 be sorted. Avoiding the use of <tt>.callee</tt>, to allow <tt>_.isArray</tt>
4145 to work properly in ES5's strict mode.
4146 </p>
4147
4148 <p id="1.1.3">
4149 <b class="header">1.1.3</b> &mdash; <small><i>December 1, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.2...1.1.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.3/index.html">Docs</a><br />
4150 In CommonJS, Underscore may now be required with just: <br />
4151 <tt>var _ = require("underscore")</tt>.
4152 Added <tt>_.throttle</tt> and <tt>_.debounce</tt> functions.
4153 Removed <tt>_.breakLoop</tt>, in favor of an ES5-style un-<i>break</i>-able
4154 each implementation &mdash; this removes the try/catch, and you'll now have
4155 better stack traces for exceptions that are thrown within an Underscore iterator.
4156 Improved the <b>isType</b> family of functions for better interoperability
4157 with Internet Explorer host objects.
4158 <tt>_.template</tt> now correctly escapes backslashes in templates.
4159 Improved <tt>_.reduce</tt> compatibility with the ES5 version:
4160 if you don't pass an initial value, the first item in the collection is used.
4161 <tt>_.each</tt> no longer returns the iterated collection, for improved
4162 consistency with ES5's <tt>forEach</tt>.
4163 </p>
4164
4165 <p id="1.1.2">
4166 <b class="header">1.1.2</b> &mdash; <small><i>October 15, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.1...1.1.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.2/index.html">Docs</a><br />
4167 Fixed <tt>_.contains</tt>, which was mistakenly pointing at
4168 <tt>_.intersect</tt> instead of <tt>_.include</tt>, like it should
4169 have been. Added <tt>_.unique</tt> as an alias for <tt>_.uniq</tt>.
4170 </p>
4171
4172 <p id="1.1.1">
4173 <b class="header">1.1.1</b> &mdash; <small><i>October 5, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.0...1.1.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.1/index.html">Docs</a><br />
4174 Improved the speed of <tt>_.template</tt>, and its handling of multiline
4175 interpolations. Ryan Tenney contributed optimizations to many Underscore
4176 functions. An annotated version of the source code is now available.
4177 </p>
4178
4179 <p id="1.1.0">
4180 <b class="header">1.1.0</b> &mdash; <small><i>August 18, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.4...1.1.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.1.0/index.html">Docs</a><br />
4181 The method signature of <tt>_.reduce</tt> has been changed to match
4182 the ES5 signature, instead of the Ruby/Prototype.js version.
4183 This is a backwards-incompatible change. <tt>_.template</tt> may now be
4184 called with no arguments, and preserves whitespace. <tt>_.contains</tt>
4185 is a new alias for <tt>_.include</tt>.
4186 </p>
4187
4188 <p id="1.0.4">
4189 <b class="header">1.0.4</b> &mdash; <small><i>June 22, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.3...1.0.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.0.4/index.html">Docs</a><br />
4190 <a href="https://themoell.com/">Andri Möll</a> contributed the <tt>_.memoize</tt>
4191 function, which can be used to speed up expensive repeated computations
4192 by caching the results.
4193 </p>
4194
4195 <p id="1.0.3">
4196 <b class="header">1.0.3</b> &mdash; <small><i>June 14, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.2...1.0.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.0.3/index.html">Docs</a><br />
4197 Patch that makes <tt>_.isEqual</tt> return <tt>false</tt> if any property
4198 of the compared object has a <tt>NaN</tt> value. Technically the correct
4199 thing to do, but of questionable semantics. Watch out for NaN comparisons.
4200 </p>
4201
4202 <p id="1.0.2">
4203 <b class="header">1.0.2</b> &mdash; <small><i>March 23, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.1...1.0.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.0.2/index.html">Docs</a><br />
4204 Fixes <tt>_.isArguments</tt> in recent versions of Opera, which have
4205 arguments objects as real Arrays.
4206 </p>
4207
4208 <p id="1.0.1">
4209 <b class="header">1.0.1</b> &mdash; <small><i>March 19, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.0...1.0.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.0.1/index.html">Docs</a><br />
4210 Bugfix for <tt>_.isEqual</tt>, when comparing two objects with the same
4211 number of undefined keys, but with different names.
4212 </p>
4213
4214 <p id="1.0.0">
4215 <b class="header">1.0.0</b> &mdash; <small><i>March 18, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.6.0...1.0.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.0.0/index.html">Docs</a><br />
4216 Things have been stable for many months now, so Underscore is now
4217 considered to be out of beta, at <b>1.0</b>. Improvements since <b>0.6</b>
4218 include <tt>_.isBoolean</tt>, and the ability to have <tt>_.extend</tt>
4219 take multiple source objects.
4220 </p>
4221
4222 <p id="0.6.0">
4223 <b class="header">0.6.0</b> &mdash; <small><i>February 24, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.8...0.6.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.6.0/index.html">Docs</a><br />
4224 Major release. Incorporates a number of
4225 <a href="https://github.com/ratbeard">Mile Frawley's</a> refactors for
4226 safer duck-typing on collection functions, and cleaner internals. A new
4227 <tt>_.mixin</tt> method that allows you to extend Underscore with utility
4228 functions of your own. Added <tt>_.times</tt>, which works the same as in
4229 Ruby or Prototype.js. Native support for ES5's <tt>Array.isArray</tt>,
4230 and <tt>Object.keys</tt>.
4231 </p>
4232
4233 <p id="0.5.8">
4234 <b class="header">0.5.8</b> &mdash; <small><i>January 28, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.7...0.5.8">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.8/index.html">Docs</a><br />
4235 Fixed Underscore's collection functions to work on
4236 <a href="https://developer.mozilla.org/En/DOM/NodeList">NodeLists</a> and
4237 <a href="https://developer.mozilla.org/En/DOM/HTMLCollection">HTMLCollections</a>
4238 once more, thanks to
4239 <a href="https://github.com/JustinTulloss">Justin Tulloss</a>.
4240 </p>
4241
4242 <p id="0.5.7">
4243 <b class="header">0.5.7</b> &mdash; <small><i>January 20, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.6...0.5.7">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.7/index.html">Docs</a><br />
4244 A safer implementation of <tt>_.isArguments</tt>, and a
4245 faster <tt>_.isNumber</tt>,<br />thanks to
4246 <a href="https://jedschmidt.com/">Jed Schmidt</a>.
4247 </p>
4248
4249 <p id="0.5.6">
4250 <b class="header">0.5.6</b> &mdash; <small><i>January 18, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.5...0.5.6">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.6/index.html">Docs</a><br />
4251 Customizable delimiters for <tt>_.template</tt>, contributed by
4252 <a href="https://github.com/iamnoah">Noah Sloan</a>.
4253 </p>
4254
4255 <p id="0.5.5">
4256 <b class="header">0.5.5</b> &mdash; <small><i>January 9, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.4...0.5.5">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.5/index.html">Docs</a><br />
4257 Fix for a bug in MobileSafari's OOP-wrapper, with the arguments object.
4258 </p>
4259
4260 <p id="0.5.4">
4261 <b class="header">0.5.4</b> &mdash; <small><i>January 5, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.2...0.5.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.4/index.html">Docs</a><br />
4262 Fix for multiple single quotes within a template string for
4263 <tt>_.template</tt>. See:
4264 <a href="https://www.west-wind.com/Weblog/posts/509108.aspx">Rick Strahl's blog post</a>.
4265 </p>
4266
4267 <p id="0.5.2">
4268 <b class="header">0.5.2</b> &mdash; <small><i>January 1, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.1...0.5.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.2/index.html">Docs</a><br />
4269 New implementations of <tt>isArray</tt>, <tt>isDate</tt>, <tt>isFunction</tt>,
4270 <tt>isNumber</tt>, <tt>isRegExp</tt>, and <tt>isString</tt>, thanks to
4271 a suggestion from
4272 <a href="https://www.broofa.com/">Robert Kieffer</a>.
4273 Instead of doing <tt>Object#toString</tt>
4274 comparisons, they now check for expected properties, which is less safe,
4275 but more than an order of magnitude faster. Most other Underscore
4276 functions saw minor speed improvements as a result.
4277 <a href="https://dolzhenko.org/">Evgeniy Dolzhenko</a>
4278 contributed <tt>_.tap</tt>,
4279 <a href="https://ruby-doc.org/core-1.9/classes/Object.html#M000191">similar to Ruby 1.9's</a>,
4280 which is handy for injecting side effects (like logging) into chained calls.
4281 </p>
4282
4283 <p id="0.5.1">
4284 <b class="header">0.5.1</b> &mdash; <small><i>December 9, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.0...0.5.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.1/index.html">Docs</a><br />
4285 Added an <tt>_.isArguments</tt> function. Lots of little safety checks
4286 and optimizations contributed by
4287 <a href="https://github.com/iamnoah">Noah Sloan</a> and
4288 <a href="https://themoell.com/">Andri Möll</a>.
4289 </p>
4290
4291 <p id="0.5.0">
4292 <b class="header">0.5.0</b> &mdash; <small><i>December 7, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.7...0.5.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.5.0/index.html">Docs</a><br />
4293 <b>[API Changes]</b> <tt>_.bindAll</tt> now takes the context object as
4294 its first parameter. If no method names are passed, all of the context
4295 object's methods are bound to it, enabling chaining and easier binding.
4296 <tt>_.functions</tt> now takes a single argument and returns the names
4297 of its Function properties. Calling <tt>_.functions(_)</tt> will get you
4298 the previous behavior.
4299 Added <tt>_.isRegExp</tt> so that <tt>isEqual</tt> can now test for RegExp equality.
4300 All of the "is" functions have been shrunk down into a single definition.
4301 <a href="https://github.com/grayrest">Karl Guertin</a> contributed patches.
4302 </p>
4303
4304 <p id="0.4.7">
4305 <b class="header">0.4.7</b> &mdash; <small><i>December 6, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.6...0.4.7">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.7/index.html">Docs</a><br />
4306 Added <tt>isDate</tt>, <tt>isNaN</tt>, and <tt>isNull</tt>, for completeness.
4307 Optimizations for <tt>isEqual</tt> when checking equality between Arrays
4308 or Dates. <tt>_.keys</tt> is now <small><i><b>25%&ndash;2X</b></i></small> faster (depending on your
4309 browser) which speeds up the functions that rely on it, such as <tt>_.each</tt>.
4310 </p>
4311
4312 <p id="0.4.6">
4313 <b class="header">0.4.6</b> &mdash; <small><i>November 30, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.5...0.4.6">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.6/index.html">Docs</a><br />
4314 Added the <tt>range</tt> function, a port of the
4315 <a href="https://docs.python.org/library/functions.html#range">Python
4316 function of the same name</a>, for generating flexibly-numbered lists
4317 of integers. Original patch contributed by
4318 <a href="https://github.com/kylichuku">Kirill Ishanov</a>.
4319 </p>
4320
4321 <p id="0.4.5">
4322 <b class="header">0.4.5</b> &mdash; <small><i>November 19, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.4...0.4.5">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.5/index.html">Docs</a><br />
4323 Added <tt>rest</tt> for Arrays and arguments objects, and aliased
4324 <tt>first</tt> as <tt>head</tt>, and <tt>rest</tt> as <tt>tail</tt>,
4325 thanks to <a href="https://github.com/lukesutton">Luke Sutton</a>'s patches.
4326 Added tests ensuring that all Underscore Array functions also work on
4327 <i>arguments</i> objects.
4328 </p>
4329
4330 <p id="0.4.4">
4331 <b class="header">0.4.4</b> &mdash; <small><i>November 18, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.3...0.4.4">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.4/index.html">Docs</a><br />
4332 Added <tt>isString</tt>, and <tt>isNumber</tt>, for consistency. Fixed
4333 <tt>_.isEqual(NaN, NaN)</tt> to return <i>true</i> (which is debatable).
4334 </p>
4335
4336 <p id="0.4.3">
4337 <b class="header">0.4.3</b> &mdash; <small><i>November 9, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.2...0.4.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.3/index.html">Docs</a><br />
4338 Started using the native <tt>StopIteration</tt> object in browsers that support it.
4339 Fixed Underscore setup for CommonJS environments.
4340 </p>
4341
4342 <p id="0.4.2">
4343 <b class="header">0.4.2</b> &mdash; <small><i>November 9, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.1...0.4.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.2/index.html">Docs</a><br />
4344 Renamed the unwrapping function to <tt>value</tt>, for clarity.
4345 </p>
4346
4347 <p id="0.4.1">
4348 <b class="header">0.4.1</b> &mdash; <small><i>November 8, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.0...0.4.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.1/index.html">Docs</a><br />
4349 Chained Underscore objects now support the Array prototype methods, so
4350 that you can perform the full range of operations on a wrapped array
4351 without having to break your chain. Added a <tt>breakLoop</tt> method
4352 to <b>break</b> in the middle of any Underscore iteration. Added an
4353 <tt>isEmpty</tt> function that works on arrays and objects.
4354 </p>
4355
4356 <p id="0.4.0">
4357 <b class="header">0.4.0</b> &mdash; <small><i>November 7, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.3...0.4.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.4.0/index.html">Docs</a><br />
4358 All Underscore functions can now be called in an object-oriented style,
4359 like so: <tt>_([1, 2, 3]).map(...);</tt>. Original patch provided by
4360 <a href="https://macournoyer.com/">Marc-André Cournoyer</a>.
4361 Wrapped objects can be chained through multiple
4362 method invocations. A <a href="#object-functions"><tt>functions</tt></a> method
4363 was added, providing a sorted list of all the functions in Underscore.
4364 </p>
4365
4366 <p id="0.3.3">
4367 <b class="header">0.3.3</b> &mdash; <small><i>October 31, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.2...0.3.3">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.3.3/index.html">Docs</a><br />
4368 Added the JavaScript 1.8 function <tt>reduceRight</tt>. Aliased it
4369 as <tt>foldr</tt>, and aliased <tt>reduce</tt> as <tt>foldl</tt>.
4370 </p>
4371
4372 <p id="0.3.2">
4373 <b class="header">0.3.2</b> &mdash; <small><i>October 29, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.1...0.3.2">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.3.2/index.html">Docs</a><br />
4374 Now runs on stock <a href="https://www.mozilla.org/rhino/">Rhino</a>
4375 interpreters with: <tt>load("underscore.js")</tt>.
4376 Added <a href="#identity"><tt>identity</tt></a> as a utility function.
4377 </p>
4378
4379 <p id="0.3.1">
4380 <b class="header">0.3.1</b> &mdash; <small><i>October 29, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.0...0.3.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.3.1/index.html">Docs</a><br />
4381 All iterators are now passed in the original collection as their third
4382 argument, the same as JavaScript 1.6's <b>forEach</b>. Iterating over
4383 objects is now called with <tt>(value, key, collection)</tt>, for details
4384 see <a href="#each"><tt>_.each</tt></a>.
4385 </p>
4386
4387 <p id="0.3.0">
4388 <b class="header">0.3.0</b> &mdash; <small><i>October 29, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.2.0...0.3.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.3.0/index.html">Docs</a><br />
4389 Added <a href="https://github.com/DmitryBaranovskiy">Dmitry Baranovskiy</a>'s
4390 comprehensive optimizations, merged in
4391 <a href="https://github.com/kriskowal">Kris Kowal</a>'s patches to make Underscore
4392 <a href="https://wiki.commonjs.org/wiki/CommonJS">CommonJS</a> and
4393 <a href="https://narwhaljs.org/">Narwhal</a> compliant.
4394 </p>
4395
4396 <p id="0.2.0">
4397 <b class="header">0.2.0</b> &mdash; <small><i>October 28, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.1.1...0.2.0">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.2.0/index.html">Docs</a><br />
4398 Added <tt>compose</tt> and <tt>lastIndexOf</tt>, renamed <tt>inject</tt> to
4399 <tt>reduce</tt>, added aliases for <tt>inject</tt>, <tt>filter</tt>,
4400 <tt>every</tt>, <tt>some</tt>, and <tt>forEach</tt>.
4401 </p>
4402
4403 <p id="0.1.1">
4404 <b class="header">0.1.1</b> &mdash; <small><i>October 28, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.1.0...0.1.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.1.1/index.html">Docs</a><br />
4405 Added <tt>noConflict</tt>, so that the "Underscore" object can be assigned to
4406 other variables.
4407 </p>
4408
4409 <p id="0.1.0">
4410 <b class="header">0.1.0</b> &mdash; <small><i>October 28, 2009</i></small> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/0.1.1/index.html">Docs</a><br />
4411 Initial release of Underscore.js.
4412 </p>
4413
4414 <p>
4415 <a href="https://documentcloud.org/" title="A DocumentCloud Project" style="background:none;">
•4416 A DocumentCloud Project
4417 </a>
4418 </p>
4419
4420 </div>
4421
4422 </div>
4423
4424 <!-- Include Underscore, so you can play with it in the console. -->
4425 <script type="text/javascript" src="underscore-umd.js"></script>
4426 <script type="text/javascript" src="docs/main.js"></script>
4427 <script>
4428 var myNav = document.getElementById("myNav")
4429 var menu = document.getElementById('menu')
4430 myNav.addEventListener('click',(e)=>{
4431 if(e.target.tagName=="A"){
4432 menu.checked = true
4433 }
4434 })
4435 </script>
4436 </body>
4437 </html>