_.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 协议发布,并且支持最新的运行环境。 检查 构建差异 并选择一个适合您的构建差异。
In a browser:
<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.
Tested in Chrome 65-66, Firefox 58-59, IE 11, Edge 16, Safari 10-11, Node.js 6-10, & PhantomJS 2.1.1. Automated browser & CI test runs are available.