Bayu files [key, value] pairs into drawers one by one: what happens to repeated keys, and in what order do the drawers end up? Your own Map, query or array…
Why it matters
Turning a Map, a query or an array of pairs into an object is everyday work: reading a query, sending a Map as JSON, transforming config. Without fromEntries, people write long reduce calls. With entries and fromEntries, mapping over an object stays clean.
The key idea
fromEntries is the exact reverse of entries
Common mistakes
Duplicate keys Pairs with the same key: the last one wins and overwrites the earlier ones. An object cannot have twin keys.
Expecting key order and type to stay Keys become text (the number 1 becomes "1"), and whole-number keys are sorted to the front. Need the real keys or the arrival order? Keep a Map.
Forgetting every item must be a pair Every entry must be an object [key, value]. A plain array [1, 2, 3] throws a TypeError; shape the pairs first with .map().
Try it in this playground
File pairs with a repeated key The same drawer is overwritten: the last one wins.
File a number key after a text key The object moves it to the front, ascending.
Hand over a plain array like [1, 2, 3] Its items are not pairs, so the browser throws a TypeError.
Turn a Map into an object See JSON.stringify(sumber) in the panel: a Map becomes {}. The object fromEntries makes can be stringified.