Is there a better method to convert an associative array to a standard array with 0 based indexes other than manually iterating and rewriting each item?
I have an array that was generated by tallying the occurrences of certain properties and it needs to remain in that format. The current array structure is as follows:
let ASSARR = {
"abc": { "c": 5, "p": 3 },
"def": { "c": 1, "p": 10 },
"ghi": { "c": 15, "p": 7 }
};
...and so on. After filtering and sorting the array, I need to transform it into a standard array format like this:
let STARR = [
{ "i": "abc", "c": 5, "p": 3 },
{ "i": "def", "c": 1, "p": 10 },
{ "i": "ghi", "c": 15, "p": 7 }
];
Is there a more efficient way to accomplish this task without using a traditional loop such as for
?