# lodash
Lodash 是一个一致性、模块化、高性能的 JavaScript 实用工具库,https://www.lodashjs.com/
| 🐉 函数块 | 🐉 数学块 |
|---|---|
| 数字块 | 字符串 |
| 数组 |
# 安装
浏览器环境:
<script src="lodash.js"></script>
1
通过 npm:
npm i -g npm
npm i --save lodash
1
2
2
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');
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
注意
如需在 Node.js < 6 的 REPL 环境中使用 Lodash,请安装 n_。
# 为什么选择 Lodash
Lodash 通过降低 array、number、objects、string 等等的使用难度从而让 JavaScript 变得更简单。 Lodash 的模块化方法 非常适用于:
- 遍历 array、object 和 string
- 对值进行操作和检测
- 创建符合功能的函数
# 补充工具
futil-js 是一套用来补足 lodash 的实用工具集。
# 兼容性
在 Chrome 74-75、Firefox 66-67、IE 11、Edge 18、Safari 11-12 和 Node.js 8-12 环境中测试通过。
