Menu

gitpiper

objectFromPairs javascript Code Snippet in 2024

objectarraybeginner

Last Updated: 12 April 2024

Creates an object from the given key-value pairs.

  • Use 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}

javascript snippet similar to objectFromPairs For You in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️