TypeScript 物件作為 C# 中的字典型別 - TypeScript Objects as Dictionary types as in C#

語言: CN / TW / HK

問題:

I have some JavaScript code that uses objects as dictionaries;我有一些使用物件作為字典的 JavaScript 程式碼; for example a 'person' object will hold a some personal details keyed off the email address.例如,“人”物件將保留一些從電子郵件地址中刪除的個人詳細資訊。

var people = {<email> : <'some personal data'>};

adding   > "people[<email>] = <data>;" 
getting  > "var data = people[<email>];" 
deleting > "delete people[<email>];"

Is it possible to describe this in Typescript?是否可以在 Typescript 中對此進行描述? or do I have to use an Array?還是我必須使用陣列?


解決方案:

參考一: https://stackoom.com/question/vCBp
參考二: TypeScript Objects as Dictionary types as in C#
「其他文章」