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
3 answers

How can I use lodash to filter value between two date?

created_at is the value I Want to compare with the beginDate and the endDate. var newARRA = chain(this.props.transferts.transfertAccount) .filter({ 'officeSender': this.props.users.user.office,officeReceiver:this.state.selectedOffice, …
2
votes
4 answers

Transforming each item in an array into an object

I'm wondering how I can transform an each item in an array into a specified object. You can see the code below for the array I start out with and the result I'm trying to achieve. I'm trying to use the map function to no avail, and not sure if the…
Jimmy
  • 3,090
  • 12
  • 42
  • 99
2
votes
2 answers

How to convert nested array to normal array and change types?

I have the following structure of array: [{Id: Number, Attributes: {Name: String, Age: String, Height: String}}] And I want to convert it into the: [{Id: Number, Name: String, Age: Number, Height: Number}] Also how to convert "2018-12-12 09:19:40"…
user7832762
2
votes
6 answers

Compare objects recursively and put duplicate key values into array

I have three objects I need to iterate to check for duplicates to end up with a single object. If there are duplicates, I'd like to put them into an array so the user can select the best value so they all ultimately end up as strings or integers (or…
I'm Joe Too
  • 5,468
  • 1
  • 17
  • 29
2
votes
3 answers

Using lodash with stenciljs

I am trying to import lodash into my stenciljs component. I have tried multiple ways and viewed many solutions regarding this but got no luck on this. I have tried to import in the following ways: import * as _ from 'lodash'; import _ from…
Prasheel
  • 985
  • 5
  • 22
2
votes
3 answers

Is lodash built into Node?

This works without lodash installed as dependency: const _ = require('lodash'); _.each([1,2,3],console.log); (no, I have no lodash installed globally) I saw somewhere something like nodejs supports lodash by default, but now I cannot find any…
Yuri Gor
  • 1,353
  • 12
  • 26
2
votes
2 answers

Lodash unable to use chain with cherry pick import

I'm trying to use lodash (v4.17.11) features with cherry picking import in my project. When I do this: import {chain} from 'lodash'; and chain([1,2,3]).take(1) it works fine, however, if I change the import to: import chain from…
2
votes
3 answers

JavaScript find first number in array that is <= to given number

I have an array of prime numbers: const primes = [3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] I want to find the first number in this list that is <= the number given. For example ... getHighestPrimeNumber(58) ... should…
danday74
  • 52,471
  • 49
  • 232
  • 283
2
votes
4 answers

How to sort a nested array using lodash

I have a collection of objects in this array and I need to order them by the 'order' key (asc). Is there a way to sort the objects inside the array and then return the whole array? I am relying on the order as I'm using it in a v-for with a :key.…
Raj Saha
  • 49
  • 1
  • 7
2
votes
6 answers

Concat two arrays with filtering

I have two arrays. I need to combine both of them and make a new array which has dayOfWeek 2, 3, 4, 5, 6. Which means priority for the dayOfWeek is in array1. Means need to keep dayOfWeek 3, 4, 5 from array1. array1 = [ {dayOfWeek: 2, home1:…
Profer
  • 553
  • 8
  • 40
  • 81
2
votes
5 answers

javascript array-object convert one key, array value single object

I have an object like this: [ { "number": 12, "string": "hi"}, { "number": 40, "string": "bye"} ] I want: {"number": [12, 40], "string": ["hi", "bye"]} Or: {"number": "12,40", "string": "hi,bye"}
2
votes
1 answer

Lodash vulnerability in Angular project

After installing npm to the blur-admin template https://github.com/akveo/blur-admin I had a number of issues which I fixed by using the run recomendations in the npm audit dialog. However I cant fix one even after running $ npm install…
Andrew Day
  • 563
  • 10
  • 23
2
votes
3 answers

Why lodash converts my array into object?

I am new to lodash, and created a function that removes the key from the object where a value is null or blank. But when i am passing my object which contains some part as array it removes array and converts it into an object. Below is my code…
Mayur
  • 1,123
  • 3
  • 22
  • 38
2
votes
4 answers

Use JavaScript or Lodash to create multi dimensional array

I want to create a multi-dimensional array like this using Lodash or vanilla JS: [ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], etc ] This is a simplistic example since I want this pattern to continue up to…
danday74
  • 52,471
  • 49
  • 232
  • 283
2
votes
6 answers

Filtering array so it would remove all undefined objects

I need to filter an array so it would remove undefined objects from it. I tried with lodash _.filter but didn't succeed (returned completely empty array) _.filter(myArray, _.isEmpty) I'm using Angular 6 so anything with typescript or lodash would…
raouaoul
  • 681
  • 2
  • 13
  • 33
1 2 3
99
100