_.defaults({ 'a': 1 }, { 'a': 3, 'b': 2 });// → { 'a': 1, 'b': 2 }_.partition([1, 2, 3, 4], n => n % 2);// → [[1, 3], [2, 4]]
Lodash 采用 MIT license 协议发布,并且支持最新的运行环境。 Review the build differences & pick one that’s right for you.
浏览器环境:
<script src="lodash.js"></script>
通过 npm:
$ npm i -g npm$ npm i --save lodash
Node.js:
// Load the full build.var _ = require('lodash');// Load the core build.var _ = require('lodash/core');// Load the FP build for immutable auto-curried iteratee-first data-last methods.var fp = require('lodash/fp'); // Load method categories.var array = require('lodash/array');var object = require('lodash/fp/object'); // Cherry-pick methods for smaller browserify/rollup/webpack bundles.var at = require('lodash/at');var curryN = require('lodash/fp/curryN');
注意:
Install n_ for Lodash use in the Node.js < 6 REPL.
Lodash 通过降低 array、number、objects、string 等等的使用难度从而让 JavaScript 变得更简单。 Lodash 的模块化方法 非常适用于:
Lodash is available in a variety of builds & module formats.
在 Chrome 54-55、Firefox 49-50、IE 11、Edge 14、Safari 9-10、Node.js 6-7 和 PhantomJS 2.1.1 上通过测试。 Automated browser & CI test runs are available.