Iterating over Typescript Map

前端 未结 12 1820
无人共我
无人共我 2020-12-07 16:26

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:

         


        
12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 16:46

    You could use Map.prototype.forEach((value, key, map) => void, thisArg?) : void instead

    Use it like this:

    myMap.forEach((value: boolean, key: string) => {
        console.log(key, value);
    });
    

提交回复
热议问题