you-dont-need /You-Dont-Need-Lodash-Underscore
List of JavaScript methods which you can use natively + ESLint Plugin
★ 19,112⑂ 814👁 193⑃ 286● 134▤ 2
More from this author
-1
Daily
19,112
stars
814
forks
193
watchers
286
prs
134
issues
2
releases
README
You don't (may not) need Lodash/Underscore
Lodash and Underscore are great modern JavaScript utility libraries, and they are widely used by Front-end developers. However, when you are targeting modern browsers, you may find out that there are many methods which are already supported natively thanks to ECMAScript5 [ES5] and ECMAScript2015 [ES6]. If you want your project to require fewer dependencies, and you know your target browser clearly, then you may not need Lodash/Underscore.
You are welcome to contribute with more items provided below.
If you are targeting legacy JavaScript engine with those ES5 methods, you can use es5-shim
Please note that, the examples used below are just showing you the native alternative of performing certain tasks. For some functions, Lodash provides you more options than native built-ins. This list is not a 1:1 comparison.
Please send a PR if you want to add or modify the code. No need to open an issue unless it's something big and you want to discuss.
Voice of Developers
Make use of native JavaScript object and array utilities before going big.
—Cody Lindley, Author of jQuery Cookbook and JavaScript Enlightenment
You probably don't need Lodash. Nice List of JavaScript methods which you can use natively.
—Daniel Lamb, Computer Scientist, Technical Reviewer of Secrets of the JavaScript Ninja and Functional Programming in JavaScript
I guess not, but I want it.
—Tero Parviainen, Author of build-your-own-angular
I'll admit, I've been guilty of overusing lodash. Excellent resource.
—@therebelrobot, Maker of web things, Facilitator for Node.js/io.js
ESLint Plugin
If you're using ESLint, you can install a
plugin that
will help you identify places in your codebase where you don't (may not) need Lodash/Underscore.
Install the plugin ...
sh
npm install --save-dev eslint-plugin-you-dont-need-lodash-underscore
... then update your config
json
"extends" : ["plugin:you-dont-need-lodash-underscore/compatible"],
For more information, see Configuring the ESLint Plugin
[!IMPORTANT]
Note that, while many Lodash methods are null safe (e.g. _.keys, _.entries),
this is not necessarily the case for their Native equivalent. If null safety is critical for your application, we
suggest that you take extra precautions [e.g. consider using the native Object.keys as Object.keys(value || {})].
Quick Links
Array
1. _.chunk
1. _.compact
1. _.concat
1. _.difference
1. _.drop
1. _.dropRight
1. _.fill
1. _.find
1. _.findIndex
1. _.first
1. _.flatten
1. _.flattenDeep
1. _.fromPairs
1. _.head and _.tail
1. _.indexOf
1. _.intersection
1. _.isArray
1. _.isArrayBuffer
1. _.join
1. _.last
1. _.lastIndexOf
1. _.reverse
1. _.slice
1. _.without
1. _.initial
1. _.pull
1. _.unionBy
Collection
[!IMPORTANT]
Note that most native equivalents are array methods,
and will not work with objects. If this functionality is needed and no object method is provided,
then Lodash/UnderscTop issues
#149support rule documentation links for plugins14 comments · 2018-10-06#13includes support for IE 9+12 comments · 2016-01-27#127trimStart and trimEnd11 comments · 2018-04-28#342Add entry for _.shuffle6 comments · 2022-07-01#278in _.debounce , set immediate true, the debounced function cannot work5 comments · 2020-04-24#396Support eslint flat config4 comments · 2024-03-21#340Why don't you use `instanceof` for `isDate`?4 comments · 2022-04-22#309TypeScript: Examples and rules4 comments · 2021-04-23
Discussions
Latest release
v6.14.0 v6.14.0 2024-04-03What's Changed chore(deps): bump js-yaml and coveralls by @dependabot in https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/pull/375 chore(deps): bump minimist, mkdirp and mocha by @dependabot in https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/pull/376 chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 by @dependabot in https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/pull/366 chore(deps): bump ajv and eslint by @dependabot in https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/pull/367 chore(deps): bump ajv and eslint by @dep