Skip to content

下划线

¥Underscore

下划线 是一个 JavaScript 实用程序带库,提供对函数式编程的支持。它对于以函数式风格编写清晰、简洁的 JavaScript 非常有用。

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

underscore 包在客户端和服务器上都定义了 _ 命名空间。

¥The underscore package defines the _ namespace on both the client and the server.

警告

我们稍微修改了 Underscore 在 收集功能 中区分对象和数组的方式。原始的 Underscore 逻辑是将任何具有数字 length 属性的对象视为数组(这有助于它在 NodeList 上正常工作)。在 Meteor 的 Underscore 版本中,如果对象没有原型(具体来说,如果是 x.constructor === Object),则具有数字 length 属性的对象将被视为对象。

¥We have slightly modified the way Underscore differentiates between objects and arrays in collection functions. The original Underscore logic is to treat any object with a numeric length property as an array (which helps it work properly on NodeLists). In Meteor's version of Underscore, objects with a numeric length property are treated as objects if they have no prototype (specifically, if x.constructor === Object.