Skip to main content

All Questions

Tagged with
-3 votes
1 answer
964 views

How to iterate over Json object in javascript or Ecmascript? [duplicate]

I have this json Response and having difficulty in iterating over this json structure.The idea is to print the numbers written within the square brackets if they match with "Data" Json which ...
Mayo's user avatar
  • 1
-2 votes
2 answers
71 views

Find matching object property in array and merge into new object [closed]

I have an array of objects, where I want to find the objects having same value for name property and then merge them into single object by adding their values & subvalues. const arr = [ { id: 1, ...
marukobotto's user avatar
0 votes
0 answers
150 views

Create array of objects from graphql response

I have a response from graphql that I want to reformat and assign to a variable so that I can keep using them across my app. GraphQL response: { "data": { "organization"...
nb_nb_nb's user avatar
  • 1,347
-2 votes
1 answer
271 views

JavaScript get comma separated values based condition

Hi I'm having an issue filtering out the values from array of objects. So basically I've an array of object const arr = [ { "id": null, "name": null, &...
Mitul Panchal's user avatar
0 votes
1 answer
68 views

Javascript - convert array multi level to single level [duplicate]

I am trying to map a complex object array document to a single level array. For example const data = [ { "id": 1, "name": "Beauty", "...
tthuy's user avatar
  • 13
0 votes
1 answer
87 views

Passing a string as a property to use the map function

I have something like this { "title": "JSON", "content": [ { "item": "23", "url":"ug.coml" ...
Jacklyn N's user avatar
0 votes
3 answers
287 views

Is there any way to create object using function in TypeScript , like JavaScript?

I want to create Object using Function in TypeScript like JavaScript. Eg. function Box(a,b) { this.width=a; this.height=b; } var box=new Box(3,5); I tried this code in TypeScript, It throws ...
Subhasish Biswasray's user avatar
3 votes
2 answers
2k views

Add a new key and value to a Javascript object from an existing array of values

I have an existing array of ids that I'm trying to iterate over to add each as an id: key to an existing array of objects. I have tried a number of different loops (for, for in, map, forEach), but I ...
i-am-niall's user avatar
-2 votes
2 answers
83 views

Merge objects of single array on basis of object key [closed]

I'm confused to merge array contents from JavaScript. Please help to get the best way to get desired result. A i also have tried other ways referred on SO. [ { "Afghanistan": ...
Nitin's user avatar
  • 45
1 vote
2 answers
52 views

Converting object to array with objects

I need help sorting this out, I tried object.keys with map, but can't get too far, so, I have this object and each key has an array: const first = { "apples": [ "5.78", ...
ifkas's user avatar
  • 43
0 votes
3 answers
907 views

Map through a Javascript array of objects and return a new one satisfying a condition

Having the following data structure: [ { "items": [ { "name": "View Profile", "href": "/profile&...
Leo Messi's user avatar
  • 5,946
0 votes
2 answers
47 views

How to take only specific indexes and map to another indexes?

I need to make an api call with particular parameter. See example below: const apiFunc = (someId, anotherId) => apiCall(someId, anotherId) } However in an array called someArr I get something like [...
Mister Mister's user avatar
-2 votes
1 answer
57 views

How do I do "Reverse destructuring"

We all know about destructuring objects in ES6+ const myObject = {name: 'John', age: 30, eyeColor: 'brown'} const {name, age, eyeColor} = myObject ... is there a "cleaner" way to do the ...
anthony galligani's user avatar
0 votes
1 answer
65 views

Spreading array to set a new state

I am working in React.JS and trying to set a new state by spreading array of objects and changing a value of one of them. I have an array of objects with key and another object as a value. Like this: ...
rey2197's user avatar
  • 91
0 votes
5 answers
161 views

Flatten then map object to array

I have an object that needs to be mapped into array with the key as a property. The object looks like: { Cat: { value: 50 }, Dog: { value: 80 } } I need to convert this to: [ { animal:...
Jimbob's user avatar
  • 23

15 30 50 per page
1
2
3 4 5
73