Skip to main content

All Questions

Tagged with
0 votes
1 answer
43 views

Sort function to achieve custom difference along with multiple columns

Trying to achieve custom sort as below: // 1. sort by 'value' column, here 'a' (first object) and b (second object) has difference equals to 4.5 or less then 4.5 then, // consider equal values (even ...
dsi's user avatar
  • 3,369
0 votes
1 answer
80 views

How to deal with searching strings and array of strings in JS

_.get(params, "_q") outputs either string or array of strings. On my current code, when I type for example "hello, there", it translates to array of strings and as a result is says ...
Joseph's user avatar
  • 7,805
0 votes
1 answer
23 views

How to Compare 2 objects and find if a particular property has changed and if yes, set flag to false

I have 2 objects and I want to compare both. If any of the slug properties have changed(added, modified, or deleted) I want the flag to be set to false. Any other change or no changes, I want the flag ...
keerti's user avatar
  • 255
1 vote
5 answers
496 views

Find unique array of objects dynamically considering undefined values

I have a an array of objects in this format: const myArray = [ { one: 'A', two: 'AB' }, { one: undefined, two: 'AB' }, { one: 'A', two: 'BC' }, { one: undefined, two: 'CC' }, ] ...
iCodeByte's user avatar
  • 681
0 votes
1 answer
7k views

Lodash merge two objects but replace the same key values with new object value

I have two objects with some common keys but different values like below. const object1 = { name: 'John', age: 23, books: ['book1', 'book2'] }; const object2 = { name: 'John', age: 23, ...
user10518298's user avatar
2 votes
1 answer
715 views

Confused about lodash merge in this case

I understand how a simple lodash merge works but as I was playing around with it to try more complicated scenarios I got confused about how the output is being formed for instance: const a = [{ h: 1, ...
j obe's user avatar
  • 2,059
-1 votes
1 answer
266 views

JavaScript add a line break after every 12th character in a string which has HTML tags

I have a string which is a combination of many small strings, wrapped around a HTML tag. The target is to add a line break after every 12th character excluding the tags. '<span>This is a text.&...
user10518298's user avatar
1 vote
2 answers
123 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) =&...
mishraak's user avatar
2 votes
3 answers
145 views

Javascript merging duplicates in an array of objects

I have an array of objects like this- {"zone":"lobby a","time":"00:00","hub":"I","Sum":0.0,"schedule":"2022&...
Aditya R's user avatar
  • 383
1 vote
2 answers
531 views

ReferenceError: _ is not defined on an array .map() call

I'm getting a "ReferenceError: _ is not defined" on a .map call like this: arr.map(async (elem) => { ... }); There doesn't appear to be any explicit mention of "_" anywhere ...
Edward Sun's user avatar
  • 1,621
4 votes
3 answers
89 views

How to tell where an object value is undefined?

Below have I a very simple function, which I type check at compile and runtime, but I would to also rumtime check all the keys result in a value, and if it doesn't, then prompt where it broke. The ...
Sandra Schlichting's user avatar
2 votes
2 answers
116 views

JavaScript: How to Group Array of Objects with Nested Properties?

I have this array of objects: [ { "date": "08/08/2022", "name": "Swordsman", "items": [ { "item_id": 1, &...
user3233787's user avatar
0 votes
1 answer
220 views

lodash pick properties and properties from nested array in JSON

Let say I have the following JSON results = results.map(result => _.pick(result, ['id', 'vessel_type.id', 'emails[0].id'])); but only able to get the first email id How do I get all email id ...
J L's user avatar
  • 87
0 votes
1 answer
768 views

JS transform deeply nested array of objects at the top level with renaming

I would like to simplify this nested array of objects move some items at the top level with a new property name. Given this data: let data = [ { "id": 1001, "model&...
user3233787's user avatar
0 votes
1 answer
274 views

map object keys from API using ES6 lodash

I'm using Vue 3 for sending POST data to my API. The objects look like const externalResults: ref(null) const resource = ref({ id: null, name: null, state: {} }) Before sending the data to the ...
Luciano's user avatar
  • 2,196

15 30 50 per page
1
2 3 4 5
27