score:3
Accepted answer
You can simply use Array.prototype.flat for that:
console.log([
[{
id: 1
}],
[{
id: 2
}]
].flat());
score:2
One way is:
console.log([[{id: 1}], [{id: 2}]].map(arr => arr[0]))
Another way is Array.prototype.flat()
:
const arr1 = [[{id: 1}], [{id: 2}]]
console.log(arr1.flat())
Source: stackoverflow.com
Related Query
- how can i extract arrays from one array & convert them in object and put them in a new array?
- How can I extract a nested array of objects and put them in the core array?
- How can I take a values of one object and put them into another object
- How do I convert array to an array object and combine two arrays to a one array?
- How can I group specific items within an object in the same array and delete them from the core array?
- How can i extract more than one key from an Object and print the output
- How can i get array of object from this data for state and count in reactjs
- How to extract element from JSON array and put into another array
- How can one property of an object from an array be true if that property of other objects is false?
- How can I extract some data from a array of dict to put in a array?
- How can I convert this object to an array and access values by key in React?
- how can i convert array of objects to one object
- How can I pull a specific object from the state and get one of its items?
- how to destructure object of arrays from api and put into state?
- I have a multidimensional object with several layers of nested arrays and I'm trying to map through all of them in one go but not sure how to
- How can I map string array taken from mongoDB and show one specific title/body per post
- How to extract only values from array of objects and put it to an array using react and javascript?
- React/Material-UI: How can I map multiple tables from a JSON object with more than one array of data?
- How can i get values from multiple input boxes on form submit and store the values as an object in an state array for React?
- How can I Extract JSON Object that Holds Base64 and File Extension from application/json body in ASP.NET Core
- how to loop throgh array of object from axios json respone in react js and set them in div?
- How can I delete an entire json object from an array of json objects and write it out to file?
- How I can display only one object from API array Reactjs
- useState hook can only set one object at the time and return the other object of the same array to initial state
- React: How to convert JSON Object to Array and render it?
- How can I convert the object array to GraphQL format in Javascript?
- How can I extract data from this returned object in an async function?
- How can I use Promise.all on an array of objects and then reassign them to the relevant key in a new object?
- How to reduce and get value from object array using javascript
- How i can to convert array to object of array in react?
More Query from same tag
- Why can't I call localhost localhost:5000 from localhost:3000 using fetch in react?
- Material Card content overrunning icon bar
- Is there a good way to preventDefault when dispatching an action in React/Redux?
- How to replace an object property value in redux
- How to pass node as prop to component in React?
- Need to observe scroll
- css scroll snap isn't working on divs in React app
- TypeScript: Property 'icon' does not exist on type 'JSX.IntrinsicElements'
- Component not updating when mapped state changes
- Styling a specific word in a data gotten from an api which is populated on a screen
- Typescript and REST API response
- dynamic basename with BrowserRouter in react-router-dom
- How to make api call and populate in render in react function based view
- Deck.gl globe advice
- How do I select my CSS module class using document.querySelector?
- React useContext throws Invalid hook call error
- Why does my condition for my .push() in JSX return double values?
- read JSON file from local hard drive and parse into react app
- This value is overwritten Google maps in react component
- How to ensure that process.env.TZ = 'UTC'; is run first on npm run test?
- Load SCSS file dynamically on button click
- What is the type of history in typescript?
- Custom React Attributes with Brackets
- Is there a way to reduce defining and exporting language queries when building pages with i18next translations?
- how to render a video from contentful in gatsbyjs
- Using theme palette colors in custom MUI button variant
- Get React Hook Value from outside the functional component
- How to pass parameters in react functions with Typescript
- reactJs redux: how to dispatch an action on a user event and link actions with the reducers and the store
- How to exclude CSS module files from jest test suites?