使用向导 Guide

介绍是什么、它的工作原理、它的用途以及何时使用它。

Site | Docs | FP Guide | Contributing | Wiki | Code of Conduct | Twitter | Chat

Lodash 库导出为 UMD 模块。

使用 lodash-cli 生成:

shell
$ npm run build
$ lodash -o ./dist/lodash.js
$ lodash core -o ./dist/lodash.core.js

下载方式

Lodash 在 MIT 许可证 下发布,并支持现代环境。 查看 构建差异 并选择一个适合您的。

安装

使用CDN引入:

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

使用npm:

shell
$ npm i -g npm
$ npm i lodash

如果你的NPM版本小于5.0.0,需要添加 --save

使用 Node.js:

js
// Load the full build.
var _ = require('lodash')
// Load the core build.
var _ = require('lodash/core')
// 为不可变的自动柯里化 iteratee-first data-last 方法加载 FP 构建。
const fp = require('lodash/fp')

// 加载方法类别。
const array = require('lodash/array')
const object = require('lodash/fp/object')

// 用于较小的 browserify/rollup/webpack 包的 Cherry-pick 方法。
const at = require('lodash/at')
const curryN = require('lodash/fp/curryN')

正在寻找用 ES6 或更小的包大小编写的 Lodash 模块? 查看 lodash-es

为什么使用Lodash?

Lodash 通过消除使用数组、数字、对象、字符串等的麻烦使 JavaScript 变得更容易。Lodash 的模块化方法非常适合:

  • 迭代数组、对象和字符串
  • 操作和测试值
  • 创建复合函数

格式化模块

Lodash 以 各种构建 和模块格式提供。

翻到头了