I am trying to find a simple way to implement a Dictionary
in TypeScript 1.8. There are several implementation suggestions on the web, but the most attractive looks like this:
var MyDictionary: { [id: number]: string };
Unfortunately, I don't really understand what this code means. MyDictionary
is of type { [id: number]: string }
, but what on earth does that mean? And, in turn, what does [id: number]: string
mean? Is this also a type? I am guessing the id
is the key, but the value appears to be nameless.
How do I, for example, iterate over the dictionary and extract the key/value pairs? I use underscore.js quite liberally in my code so suggestions for iteration and manipulation using this library appreciated.