lodash是提供模块化、性能和额外功能的现代JavaScript实用程序库。
Lodash通过消除处理数组、数字、对象、字符串等的麻烦,使JavaScript变得更容易。Lodash的模块化方法非常适合:
- 迭代数组、对象和字符串
- 操作和测试值
- 创建复合函数的值
安装:
1、在浏览器中使用
<script src="lodash.js"></script>
2、使用npm
$ npm i -g npm $ npm i --save lodash
3、在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');