Transform object into array keeping the index

Asked

Viewed 1,315 times

1

Good afternoon Friends who can help me? I have this Object Array, I needed to turn this Object into a list more keeping the Input as it is

inserir a descrição da imagem aqui

Using Map it changes the Dice:

inserir a descrição da imagem aqui

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

Works

  • if php uses json_decode($var, true);

  • Put the code that’s best.

  • Blza Leandro? So dude doing a map var array = test.map(el => Object.Keys(el). map(key => el[key])); console.log(array);

  • Willian is Javascript, I need to access after the following way: array[0]. 1024.0 to get the value 0.0748

1 answer

1


You can use the function Object.()

const original = {0: 0.08075, 1024.0: 51200.0}
const map = new Map(Object.entries(original));
console.log(map);
  • Opá, Valeu pedro, that’s right, but still returned me only array more that way I can already work the data. Thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.