Javascript

What happened to Lodash pluck

25 September 2026 · 5 min read

What happened to Lodash pluck

The JavaScript utility library Lodash has long been a favorite among developers for its versatile functions simplifying array, object, and string manipulation. Among its many helpful tools, _.pluck held a special place, allowing developers to quickly extract specific property values from an array of objects. However, if you’ve updated to Lodash 4 or later, you might have noticed that _.pluck has vanished. What happened to this seemingly essential function, and what are the alternatives? This article delves into the deprecation of _.pluck, explores the reasons behind its removal, and guides you through the modern Lodash approaches for achieving the same functionality.

The Deprecation of _.pluck

Lodash 4 underwent significant changes, focusing on modularity and performance. As part of this overhaul, several functions deemed less efficient or redundant were removed, and _.pluck fell victim to this streamlining. While its disappearance might have caused initial confusion, the replacement methods offer improved flexibility and align better with the overall Lodash philosophy.

Its removal also pushed developers towards more robust and versatile methods within Lodash, promoting cleaner and potentially more efficient code. This shift aligns with the library’s continuous evolution to embrace best practices and maintain its position as a leading JavaScript utility library.

Introducing _.map with _.property

The primary successor to _.pluck is a combination of _.map and _.property. _.map iterates over each element in a collection and applies a given function. _.property creates a function that returns the value of a specified property from an object. Used together, they replicate the functionality of _.pluck elegantly.

For example, if you had an array of objects representing users and wanted to extract their names, you would use _.map(users, _.property('name')). This concisely achieves the desired result, providing a clear and performant alternative.

This approach is generally preferred over _.pluck as it leverages the power of function composition, a core principle in functional programming that Lodash embraces.

Leveraging _.get for Deeper Nesting

While _.property works well for direct property access, _.get provides a solution for accessing nested properties within objects. This handles scenarios where the property you need is several levels deep, making your code more resilient to changes in data structure.

Imagine you want to extract the street name from an array of user objects where the address is nested. _.map(users, _.get('address.street')) neatly accomplishes this, providing a robust way to navigate complex object structures.

This approach significantly improves code readability and maintainability, particularly when dealing with deeply nested data structures.

Exploring Alternatives: Native JavaScript Methods

With the advancements in JavaScript, native array methods like map have become increasingly powerful. Combined with destructuring, you can achieve the same result as _.pluck without relying on external libraries.

Using users.map(({ name }) => name) achieves the same outcome as the Lodash example mentioned earlier. This approach leverages the language’s built-in capabilities and can lead to highly performant code, especially in modern JavaScript environments. This is especially relevant when minimizing external library dependencies is a priority.

Choosing between native methods and Lodash ultimately depends on the specific project needs and coding style preferences. Consider factors like existing dependencies and the overall complexity of your project.

  • Lodash remains a powerful and versatile utility library.
  • Understanding the rationale behind changes like the removal of _.pluck helps developers adapt and write better code.

Practical Applications and Examples

Consider a scenario where you’re working with an e-commerce platform. You have an array of product objects, each containing details like name, price, and category. To quickly display a list of product names, you could use _.map(products, _.property('name')). Similarly, to extract the prices for a pricing analysis, _.map(products, _.property('price')) efficiently provides the necessary data.

  1. Identify the property you wish to extract.
  2. Use _.map in conjunction with _.property or _.get to retrieve the desired values.
  3. Process the resulting array as needed.

“In software development, change is inevitable. Embracing new methodologies and understanding the reasons behind them leads to greater efficiency and code quality.” - John Doe, Senior Software Engineer at Example Company

Infographic Placeholder: Visual comparison of _.pluck vs. _.map with _.property.

  • _.map provides a more functional approach.
  • _.get offers flexibility for nested properties.

Learn more about Lodash here. External Resources:

FAQ

Q: Is there a direct equivalent to _.pluck in Lodash 4+?

A: No, _.pluck was removed. The recommended approach is using _.map with _.property or _.get.

The deprecation of _.pluck signifies Lodash’s commitment to maintaining a streamlined and efficient library. By understanding the alternatives and embracing the more functional approaches offered by Lodash 4 and later, you can write cleaner, more maintainable code. Start using _.map with _.property or _.get and explore native JavaScript alternatives to improve your development workflow. Explore the linked resources and Lodash documentation to further enhance your understanding of modern JavaScript development.

Question & Answer :
I once used Lodash _.pluck…I loved pluck…

Realizing Lodash no longer supports pluck (as of Lodash 4.x), I’m struggling to remember what to use instead…

I went to the docs, hit cmd-f, typed ‘pluck’, but my poor abandoned friend is not even given a proper mention…not even a ‘has been replaced by’…

Can someone please remind me what I’m supposed to use instead?

Ah-ha! The Lodash Changelog says it all…

“Removed _.pluck in favor of _.map with iteratee shorthand”

var objects = [{ 'a': 1 }, { 'a': 2 }]; // in 3.10.1 _.pluck(objects, 'a'); // → [1, 2] _.map(objects, 'a'); // → [1, 2] // in 4.0.0 _.map(objects, 'a'); // → [1, 2]