Oct1a

Lodash库的使用

Lodash 是一个一致性、模块化、高性能的 JavaScript 实用工具库。

为什么选择 Lodash ?
Lodash 通过降低 ** array、number、objects、string **等等的使用难度从而让 JavaScript 变得更简单。
Lodash 的模块化方法 非常适用于:

  • 遍历 array、object 和 string
  • 对值进行操作和检测
  • 创建符合功能的函数

安装

浏览器环境

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>

npm

$ npm i -g npm
$ npm i --save lodash

Node.js使用Lodash

// 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');

⭐相关链接

官方文档
Lodash中文文档

本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可。