arrow_back Back to Notebook
typescript
typescript
Invalid Date

How to iterate over a map in 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
})

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch