主题
中文文档
安装
¥Installation
在浏览器中:
¥In a browser:
html
<script src="lodash.js"></script>
使用 npm:
¥Using npm:
shell
$ npm i -g npm
$ npm i --save lodash
在 Node.js 中:
¥In Node.js:
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');
注意:在 Node.js < 6 REPL 中安装 n_ 以供 Lodash 使用。
¥Note: Install n_ for Lodash use in the Node.js < 6 REPL.
为什么选择 Lodash?
¥Why Lodash?
Lodash 让 JavaScript 变得更容易,因为它省去了处理数组、数字、对象、字符串等的麻烦。Lodash 的模块化方法非常适合:
¥Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. Lodash’s modular methods are great for:
迭代数组、对象和字符串
¥Iterating arrays, objects, & strings
操作和测试值
¥Manipulating & testing values
创建复合函数
¥Creating composite functions
模块格式
¥Module Formats
Lodash 提供 各种构建 和模块格式。
¥Lodash is available in a variety of builds & module formats.