📜  typescript key as string - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:17.883000             🧑  作者: Mango

代码示例1
// This is a key/value structure. The key is a string and the value is a boolean. For example:
let map : { [key: string]: boolean} = {};
map["foo"] = true;
map["bar"] = false;
map.foo = true;
map["foobar"] = "foo"; // Throws exception
map[1] = true; // Curiously doesn't throws exception