Dev Helpers
← Back

Initialize a typed Map

Initialize a typed Map using TypeScript.

Open this example in the interactive library

Source code

const entries: readonly (readonly [string, number])[] = [
  ["api", 2],
  ["web", 4],
];
console.log([...new Map<string, number>(entries)]);

Sample output

[ [ 'api', 2 ], [ 'web', 4 ] ]