I\'m trying to iterate over a typescript map but I keep getting errors and I could not find any solution yet for such a trivial problem.
My code is:
If you don't really like nested functions, you can also iterate over the keys:
myMap : Map;
for(let key of myMap) {
if (myMap.hasOwnProperty(key)) {
console.log(JSON.stringify({key: key, value: myMap[key]}));
}
}
Note, you have to filter out the non-key iterations with the hasOwnProperty
, if you don't do this, you get a warning or an error.