VideosMy ProjectsProgramming BlogGallery
  1. Home
  2. Blog
  3. How to iterate over a map in Typescript
Programming Blog

Atom/RSS Feed

typescript

How to iterate over a map in Typescript

typescript

You can iterate over a map using the forEach method.

For example

Given the map:

const myMap: Map<string, number> = new Map();

myMap.set('a', 1);
myMap.set('b', 2);
myMap.set('c', 3);
myMap.forEach((value: string, key: number) => {
    // do something
})
Join my mailing list