Questions tagged [lodash]

A modern JavaScript utility library delivering modularity, performance, and extras.

Lodash is a JavaScript utility library delivering consistency, customization, performance, and extra features. It includes an Underscore.js build that can be used as a replacement for , and indeed its functionality is a superset of Underscore.js's.

It comes in a "modern" build for newer browsers, a compatibility build for older browsers and , and per-method builds (individual features).

Lodash’s modular methods are great for:

  • Iterating arrays, objects, & strings
  • Manipulating and testing values
  • Creating composite functions
  • Creating your own mixin for Lodash

Useful links:

6953 questions
2
votes
4 answers

Sort by parent (topological sort) and importance of element on array

Well, I have an array with objects where some elements depends of others elements. So, I need to order it by importance (dependency of parent) to store this on a database and replace all the children's parent property by the respective parent…
Olaf Erlandsen
  • 5,817
  • 9
  • 41
  • 73
2
votes
2 answers

Cannot access object fields using lodash: Error cannot access objects element

export default { configuration: { site: { control:[ api: { 'list': '/api/v1/config/sites', 'post': '/api/v1/config/sites/', 'patch': '/api/v1/config/sites/', 'delete':…
Abdulla Thanseeh
  • 9,438
  • 3
  • 11
  • 17
2
votes
2 answers

Recursively iterate over a nested object to change a key value on all occurrences

There is an input structure with rules nested inside other rules. In the rules array, wherever there is a 'data' property, its value has to be changed to "foo" Sample input objects: {condition: 'and', rules: [{data: '123'}]} {condition: 'or',…
Rk R Bairi
  • 1,289
  • 7
  • 15
  • 39
2
votes
2 answers

Can lodash remove arrays containing only null or undefined?

I have a data object that looks like this: var obj = { "one": null, "two": undefined, "three": [undefined], "four": "valid value" } And I need to end up with this: { "four": "valid value" } I'm using lodash…
2
votes
2 answers

Analog Ramda.pathOr in lodash library

What is method equal ramda.pathOr in lodash library? R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" How I can write this lodash syntax?
2
votes
2 answers

How to group an array of objects by key?

How do you group an array of objects by an object key to create a new array of objects based on the grouping? For example, I have an array of car objects: const array = [ {red: [ {height: 50} ]}, {green: [ {height: 20} ]}, {blue: [ {height:…
sonicmario
  • 601
  • 8
  • 22
2
votes
3 answers

Vue.js - Create letter headers for alphabetically sorted list

I am iterating through a JSON object of the following type: "entries": [{ "first_name": "Brigitte", "last_name": "Bardot", "country": "Paris, France", "profession": "Actress" }, { "first_name": "Apollo", "last_name":…
ogot
  • 341
  • 2
  • 17
2
votes
4 answers

Reduce array containing near-identical objects

I'm trying to find an efficient and short-as-possible way to collapse near-identical objects in an array into objects containing their own arrays with the nonidentical data. It sounds complicated when I try to explain it, let me rather show you what…
SeriousLee
  • 1,301
  • 4
  • 20
  • 42
2
votes
2 answers

How to filter the selected checkbox using angularJS

Listed all the array of object as a lists using ng-repeat and added checkbox for each value. Here I want to filter the checkbox and form a new JSON on click Apply Filter based on check/uncheck the value(Checkbox's). Actual I've tried adding the…
kabeer rifaye
  • 417
  • 2
  • 8
  • 18
2
votes
5 answers

Simple way to turn array of objects into object with grouped keys as arrays

I am looking for a simple way to do the following. I have tried to do this with lodash.reduce and it is clunky, is there an easier way. From: [{a: 'meow'}, {a: 'woof'}] To: {a: ['meow', 'woof']}
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
2
votes
4 answers

Difference between two array when elements are array

var a = [["Green","Medium"],["Green","Small"],["Medium","Red"],["Red","Small"]]; var b = [["Green","Medium"],["Green","Small"],["Medium","Red"]]; So my result will [["Red","Small"]] Not that a.filter(x => !b.includes(x)) won't work because all…
Imran
  • 3,031
  • 4
  • 25
  • 41
2
votes
0 answers

looping through dynamic array using lodash _.forEach

I want to populate a dynamic nested array through lodash where it would change according to my no:of select input fields in vue.js For example for a category it may have 3 select input fields(size,color,material) and 2 input field(size,material) for…
2
votes
1 answer

How to use lodash to throttle multiple buttons with 1 throttle?

I'd like to avoid concurrence and restrict the action by 1 per second. This is because the onChange event also trigger a slide show of 1s duration, and triggering twice is corrupting the UI. I initially started with 4 debounces function, but finally…
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
2
votes
1 answer

Debugging of Lodash chain functions

How to debug lodash chain functions in browser. Ex: if (_.size(_.values(_.omit(this.user, 'language')).filter(Boolean)) < 2) If we want to debug _.omit(this.user, 'language') and then the end result with another function _.values() as shown in the…
2
votes
1 answer

_.orderBy nested object property multiple by lodash

I have this array: [{ "group": "admin", "menuorder": 8, "screen": [{ "role": "name4", "order": 1, "ui": [{ "info": "Grey", "name": "Dog", "MenuOrder": 5 }] }, { …
1 2 3
99
100