underscore

Documentation of Meteor's underscore package.

Underscore is a utility-belt library forJavaScript that provides support for functional programming. It isinvaluable for writing clear, concise JavaScript in a functional style.

The underscore package defines the _ namespace on both the clientand the server.

Currently, underscore is included in all projects, as the Meteorcore depends on it. _ is available in the global namespace on both theclient and the server even if you do not include this package. Howeverif you do use underscore in your application, you should still add thepackage as we will remove the default underscore in the future.

We have slightly modified the way Underscore differentiates betweenobjects and arrays in collection functions.The original Underscore logic is to treat any object with a numeric lengthproperty as an array (which helps it work properly onNodeLists).In Meteor’s version of Underscore, objects with a numeric length propertyare treated as objects if they have no prototype (specifically, ifx.constructor === Object.