Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141396

Javascript - How to assign the first element of an object in array to be the key of another array

$
0
0

Basically I have an array with organisations = [] that I fill with an SQL query. This makes the array like organisations = [ {id1, name1, type1}, {id2, name2, type2}]

I want to create another array where the key of the array objects is the first element of the objects inside organisations, so they would be id1, id2 etc etc.

I think the output should be like newArray = [id1: {name1, type2}, id2: {name2, type2}]


Viewing all articles
Browse latest Browse all 141396

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>