Is key,value pair available in typescript? If yes how to do that. Can anyone provide sample example links.
Is key-value pair available in Typescript?
Yes. Called an index signature:
interface Foo {
[key: string]: Bar;
}
let foo:Foo = {};
Here keys are string
and values are Bar
.
You can use an es6 Map
for proper dictionaries, polyfilled by core-js
.