O'Reilly logo

Learning Underscore.js by Alex Pop

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Underscore and JavaScript standards

Up until Underscore 1.6, there was a strong correlation between the library and some of the native JavaScript functions available in ES5. Starting with Underscore 1.7, this link was broken and the library introduced implementations that performed better than the native JavaScript equivalents. For example, the native JavaScript functions operating on arrays make provisions for so called sparse arrays. In JavaScript, arrays behave similarly to objects: they can contain elements at arbitrary indexes even if the initial length is less than the index value, as shown in this code snippet:

var arr = [];
arr[5] = null;
arr[12] = 1;
console.log("Array length is " + arr.length);

The array length is now 13, and as it only ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required