View profile

What Does Lodash Have That Vanilla JS Doesn't?

Many of the JavaScript language's newest features are heavily inspired by Lodash and its predecessor
What Does Lodash Have That Vanilla JS Doesn't?
By Mastering JS Weekly • Issue #28 • View online
Many of the JavaScript language’s newest features are heavily inspired by Lodash and its predecessor Underscore.js. Here’s a few functions that were part of Lodash before they were part of JavaScript:
  • String#trimStart() and String#trimEnd() are part of ES2019. _.trimStart() and _.trimEnd() were part of Lodash 3 in 2015.
  • Array#flat() from ES2019 is based on _.flatten(), which was part of Lodash 1.x in 2013.
  • Object.assign() was introduced in 2015, based on .assign(), which dates back to Lodash 1.x.
Native JavaScript also has introduced several features that largely replace certain Lodash functions. For example, optional chaining is largely a replacement for Lodash’s get() function.
So what helpers does Lodash offer that native JavaScript doesn’t yet? Here are some of the important ones:
  • pick() and omit(): Create a new object with a subset of properties from an existing object.
  • <a href=“https://lodash.com/docs/4.17.15#cloneDeep” target=“blank”>cloneDeep() and merge() both perform a recursive deep clone. Native JavaScript only supports shallow cloning right now.
  • debounce() makes sure a function can only execute once in a given amount of time. This is useful for implementing autocompletes, and Lodash’s debounce() is the go-to implementation in JavaScript.

Most Recent Tutorials
Other Interesting Reads
Working With PDFs in Node.js Using pdf-lib | www.thecodebarbarian.com
Lodash vs Underscore: Dash of the Titans | Semmle Blog
GitHub - you-dont-need/You-Dont-Need-Lodash-Underscore: List of JavaScript methods which you can use natively + ESLint Plugin
Did you enjoy this issue?
Mastering JS Weekly

A weekly summary of our tutorials

If you don't want these updates anymore, please unsubscribe here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue