Languages
[Edit]
EN

JavaScript - use lodash to compare array items existence without order

0 points
Created by:
Aleena
694

In this article, we would like to show you how to use lodash to compare if arrays are the same but with changed items order in JavaScript.

Practical examples

Edit

Example 1

Edit

In this example, we use _.isEqual() method with sort() to check if array items are the same (or the same with changed order).

Example 2

Edit

In this example, we use _.isEqual() method with _.sortBy() to compare arrays.

 

References

Edit
  1. Lodash Documentation - isEqual()
  2. Lodash Documentation - sortBy()
  3. Array.prototype.sort() - JavaScript | MDN

Alternative titles

  1. JavaScript - use lodash to compare jagged arrays (items existence without order)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join