I have a array:
arr = [ ['1', 'a'], ['12', 'b'], ['2', 'c'] ];
I'm using Object.fromEntries()
to convert the array into objects with key/value pair.
But the problem is Object.fromEntries() seems to changing the sequence of my array based on the key, eg: I want my above array to be converted into object with the same sequnce as shown in the code:
expected o/p:
{1: 'a', 12: 'b', 2: 'c'}
Actual o/p from the fromEntires()
{1: 'a', 2: 'c', 12: 'b'}
any idea why does the function do that and if there is a way to avoid this and render the same sequcne as provided in the array?