You can add a key-value pair to a TypeScript or JavaScript Map using the set method. Here is an example:
index.ts243 chars10 linesIn the code above, we create a new Map with the new keyword. Then, we use the set method to add two key-value pairs to the Map. The first key is a string and the value is also a string. The second key is a number and the value is an object.
Finally, we log the Map to the console to see the result. The output should be:
index.ts54 chars2 linesgistlibby LogSnag