Array.prototype.reduce()
to create and combine key-value pairs.const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {});
objectFromPairs([['a', 1], ['b', 2]]); // {a: 1, b: 2}
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️