lodash v3.10.1

这是一个具有一致接口、模块化高性能特性的 JavaScript 工具库。

_.assign({ 'a': 1 }, { 'b': 2 }, { 'c': 3 });
// → { 'a': 1, 'b': 2, 'c': 3 }
_.map([1, 2, 3], function(n) { return n * 3; });
// → [3, 6, 9]

文档

下载

Review the build differences & pick the one that’s right for you.

模块格式

lodash is also available in a variety of other builds & module formats.

CDN copies are available on cdnjs & jsDelivr.
Create custom builds with only the features you need.
Looking for more functional usage? Try lodash-fp.

深入了解

Check out our changelog, roadmap, as well as community created podcasts, posts, & videos.

安装

In a browser:

<script src="lodash.js"></script>

In an AMD loader:

require(['lodash'], function(_) {});

Using npm:

$ {sudo -H} npm i -g npm
$ npm i --save lodash

In Node.js/io.js:

// load the modern build
var _ = require('lodash');
// or a method category
var array = require('lodash/array');
// or a method (great for smaller builds with browserify/webpack)
var chunk = require('lodash/array/chunk');

See the package source for more details.

Note:
Don’t assign values to the special variable_” when in the REPL.
Install n_ for a REPL that includes lodash by default.

Features

Support

Tested in Chrome 45-46, Firefox 40-41, IE 6-11, MS Edge, Safari 8-9, ChakraNode 0.12.2, Node.js 0.8.28, 0.10.40, 0.12.7, 4.2.2, & 5.0.0, & PhantomJS 1.9.8.

Automated browser & CI test runs are available. Special thanks to Sauce Labs for providing automated browser testing.