I created Lodash to provide more consistent cross-environment iteration support for arrays, strings, objects, and arguments
objects1. It has since become a superset of Underscore.js, providing more consistent API behavior, more features http://lodash.com (like AMD support, deep clone, and deep merge), more thorough documentation http://lodash.com/docs and unit tests (tests which run in Node.js https://en.wikipedia.org/wiki/Node.js, RingoJS https://github.com/ringo/ringojs, Rhino https://en.wikipedia.org/wiki/Rhino_%28JavaScript_engine%29, Narwhal https://github.com/tlrobinson/narwhal, PhantomJS https://en.wikipedia.org/wiki/PhantomJS, and browsers), better overall performance and optimizations for large arrays/object iteration, and more flexibility with custom builds http://lodash.com/ and template pre-compilation utilities.
因为 Lodash 的更新比 Underscore.js 更频繁,lodash underscore
build 提供 http://lodash.com/确保与 Underscore.js 最新稳定版本的兼容性。
有一次我什至被给予推送访问 https://s3.amazonaws.com/f.cl.ly/items/2e0O0S010f2A3s1W283U/push_access.png?v=ba693725到 Underscore.js,部分原因是 Lodash 负责提出 30 多个问题; Underscore.js v1.4.x+ 中的错误修复、新功能和性能提升。
除此之外,至少还有三个骨干网.js https://en.wikipedia.org/wiki/Backbone.js默认情况下包含 Lodash 的样板文件现在在 Backbone.js 的官方中提到了 Lodash文档 http://backbonejs.org/#downloads.
查看 Kit Cambridge 的帖子,向 Lo-Dash 说“你好” https://web.archive.org/web/20180101093627/http://kitcambridge.be/blog/say-hello-to-lo-dash/,更深入地了解 Lodash 和 Underscore.js 之间的差异。
脚注:
- Underscore.js 对数组、字符串、对象的支持不一致
arguments
对象。在较新的浏览器中,Underscore.js 方法会忽略数组中的空洞 http://www.2ality.com/2012/06/dense-arrays.html, “对象”方法迭代arguments
对象、字符串被视为类似数组,并且方法正确地迭代函数(忽略它们的“prototype”属性)和对象(迭代“toString”和“valueOf”等隐藏属性),而在旧版浏览器中则不会。另外,Underscore.js 方法,例如_.clone
,保留数组中的洞,而其他人喜欢_.flatten
don't.