All Questions
42
questions
1
vote
2
answers
107
views
JS/lodash - Can we efficiently change an 'array of Object' having value 'Array of Object' into array of Object with single array values
I have used lodash to create chunks of arrays (batches).
let values = {
'key1' : [lotsOfValues1],
'key2' : [lotsOfValues2]
};
let keys = ['key1', 'key2'];
let arrObj = [];
keys.forEach((key) =&...
1
vote
6
answers
1k
views
Create an array of object properties for each item that has the same key
I'm merging two objects together to create a filter object. However I want to group the merged objects property values where the keys are the same.
So...
[{category: 'furniture'}, {category: 'mirrors'}...
3
votes
3
answers
3k
views
Update an array of objects using another array
i need to update the array of objects based on another array in ES6.
Example
let a = [
{ id : 23, active :false, status:"" },
{ id : 33, active :false, status:"" },
{ id : ...
0
votes
2
answers
53
views
Retrieve nested object into array in es6 or lodash
I am trying to extract nested objects of same keys into an array from array of objects.
Example:
There is an array as shown below:
[
{
id:1,
model:'car',
manufacturer:{
id:1,
name:'...
1
vote
4
answers
550
views
How to give name for undefined object key which generate by lodash groupBy()?
The result of lodash groupBy() gives { "student": [], "undefined": [] }.
const splittedData = _.groupBy(datas, 'type');
Is it possible to give name for the key undefined ?
const datas = [
{
...
-1
votes
4
answers
120
views
Javascript compare two object keys making new object [closed]
I have two objects. If a key appears in both objects, I want the first object's value as a key and second object's value as a value.
var obj1 = {a:"value1",b:"value2",c:"value3"}
var obj2 = {a:"...
0
votes
1
answer
603
views
run into Cannot read property 'push' of undefined in lodash's reduce function
I am beginner using reduce function and lodash library, I am trying to have array referred to as result here, but I run into some situation like below.
let result: Array<number> = [];
...
3
votes
4
answers
104
views
How do we reduce nested arrays?
My object which maps student id with marks is as follows:
[
{id: 111, marks: [{sub: 'eng', mark: 90}, {sub: 'maths', mark: 20}]},
{id: 222},
{id: 333, marks: []},
{id: 444, marks: [{...
0
votes
3
answers
62
views
Add values to object in JS when using groupBy
I am using mapValues and groupBy to group and create keys when two items have the same typeId.
For example the original data is
{
"Name": "One",
"typeId": 1
},
{
"Name": "Two",
"...
1
vote
5
answers
91
views
How to use array filter criteria agaist object in lodash?
How to filter object ageist another object in lodash? but the criteria object is array..
var form = { type: ['xyz', 'abc'], name: 'pre-1' }
var items = [
{ type: 'xyz', name: 'pre-1' },
{ type: '...
4
votes
2
answers
2k
views
Lodash uniqWith, how say lodash keep last duplicate
Hello i'm using lodash uniqWith method for remove duplicated items which have same id in my array.
but lodash keep first duplicated item.
But i wan't to keep last duplicated item.
what can i do ...
4
votes
3
answers
5k
views
How to combine Lodash _.forEach() with _.groupBy
I have an object with arrays of objects. I'm trying to loop through these arrays with _.forEach() and then group each array with _.groupBy(). But the function is just returning the original data.
...
0
votes
5
answers
81
views
How to filter data with lodash
I have code as follows:
data = [
{id: "15130", state: "INITIAL"},
{id: "15129", state: "LOCKED"},
{id: "10314", state: "APPROVED"},
{id: "51", state: "APPROVED"},
{id: "10313", state: "...
0
votes
4
answers
3k
views
How to use lodash filter and map in one string
I have code which use 2 lodash method filter and map
const filtered_holidays = filter(holidays, day => day.holiday === 1);
const type_calendar_holidays = map(filtered_holidays, 'day');
How to ...
2
votes
2
answers
118
views
How to nest multiple groupby with loadash/javascript
Thank you in advance to whoever can help me. I am trying to display data using SectionList in React Native. I have written my code below displaying what I am trying to accomplish. A regular javascript ...