Object.entries
Object.entries
The Object.entries method in Javascript enables you to convert an object into an array of key value pairs.
What this means is that each item in the array created by Object.entries is itself an array of two items, the first being the key of the item and the second being the value of the item.
So if you passed in an object with a single property which was "apples" with a value of 5 ({ apple: 5 }
), then Object.entries would convert it into an array containing 1 item where the item would be an array. At the 0th index of the array would be "apples" and at the first index of the array would be the value 5 ([["apples", 5]]
).
{ apples: 5, oranges: 3 } => [["apples", 5], ["oranges", 3]]