Transform object into array while maintaining index

1

Good evening Friends who can help me? I have this Array of objects, I needed to make this Object in list more while keeping the index as it is

UsingMapitchangestheindex:

I then needed to access each item to perform calculations, but the comparison parameter is the index.

Obraços

    
asked by anonymous 04.07.2018 / 20:40

1 answer

1

You can use the Object.entries ()

const original = {0: 0.08075, 1024.0: 51200.0}
const map = new Map(Object.entries(original));
console.log(map);
    
04.07.2018 / 20:51