TypeScript, Looping through a dictionary

后端 未结 8 845
慢半拍i
慢半拍i 2020-12-04 11:41

In my code, I have a couple of dictionaries (as suggested here) which is String indexed. Due to this being a bit of an improvised type, I was wondering if there any suggesti

8条回答
  •  心在旅途
    2020-12-04 12:03

    Ians Answer is good, but you should use const instead of let for the key because it never gets updated.

    for (const key in myDictionary) {
        let value = myDictionary[key];
        // Use `key` and `value`
    }
    

提交回复
热议问题