How to convert an array of key-value tuples into an object with JavaScript?

To convert an array of key-value tuples into an object with JavaScript, we use the Object.fromEntries method.

For instance, we write

const arr = [
  ["cardType", "iDEBIT"],
  ["txnAmount", "17.64"],
  ["txnId", "20181"],
];

console.log(Object.fromEntries(arr));

to call Object.fromEntries with arr to convert the arr key-value pair arrays into properties of the object returned.