91

I don't quite get what the difference between Map and Record in Typescript is.

The only comparison I found was

A very useful built-in type introduced by Typescript 2.1 is Record: it allows you to create a typed map and is great for creating composite interfaces.

https://levelup.gitconnected.com/advanced-typescript-types-with-examples-1d144e4eda9e,

but typing Maps like this:

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

also works, so I don't really understand the difference.

Alexander Berndt
  • 910
  • 1
  • 6
  • 8
  • 32
    `Record` is JavaScript's Object used as a map (key-value pair). As for the difference between `Map` and Object, see [Map vs Object in JavaScript](https://stackoverflow.com/questions/18541940/map-vs-object-in-javascript) – cpplearner Jun 04 '19 at 13:30

0 Answers0