HashMap

HashMap is a type in TypeScript that represents a collection of key-value pairs. It is similar to a dictionary in Python or an object in JavaScript. HashMap is used to store data in a key-value format. It is a generic type, which means that you can specify the type of the key and the value when you create an instance of the class.

Usage

You can find usage of the HashMap type in the ArcGIS API for JavaScript SDK where property types, method parameters, and return types are defined as the HashMap type.

HashMap
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Construct a type with a set of properties K of type T
 *
 * typescript/lib/lib.es5.d.ts
 */
type Record<K extends keyof any, T> = {
    [P in K]: T;
};

/**
 * A HashMap is an object with string keys
 * that can have values of a certain type.
 * In simplest terms, it is a collection of key-value pairs.
 *
 * arcgis-js-api-4.31.d.ts
 */
type HashMap<T> = Record<string, T>;

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.