Dev Helpers
← Back

Convert typed entries to a dictionary

Convert typed entries to a dictionary using TypeScript.

Open this example in the interactive library

Source code

const entries: readonly (readonly [string, number])[] = [
  ["api", 2],
  ["web", 4],
];
console.log(Object.fromEntries(entries) as Record<string, number>);

Sample output

{ api: 2, web: 4 }