Iterating over Typescript Map

前端 未结 12 1825
无人共我
无人共我 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:53

    I'm using latest TS and node (v2.6 and v8.9 respectively) and I can do:

    let myMap = new Map();
    myMap.set("a", true);
    for (let [k, v] of myMap) {
        console.log(k + "=" + v);
    }
    

提交回复
热议问题