# Class: Map

## ProtoBuf. Map

#### new Map(fieldnon-null, contentsopt)

  Constructs a new Map. A Map is a container that is used to implement map fields on message objects. It closely follows the ES6 Map API; however, it is distinct because we do not want to depend on external polyfills or on ES6 itself.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `field` | ProtoBuf.Reflect.Field |  | Map field
  `contents` | Object.<string, *> | <optional> | Initial contents

  Source:
    - ProtoBuf.js, line 4844

### Members

#### (non-null) field :ProtoBuf.Reflect.Field

  The field corresponding to this map.

  ##### Type:

  - ProtoBuf.Reflect.Field
  Source:
    - ProtoBuf.js, line 4852

#### (non-null) keyElem :ProtoBuf.Reflect.Element

  Element instance corresponding to key type.

  ##### Type:

  - ProtoBuf.Reflect.Element
  Source:
    - ProtoBuf.js, line 4858

#### (non-null) map :Object.<string, Object>

  Internal map: stores mapping of (string form of key) -> (key, value) pair.

  We provide map semantics for arbitrary key types, but we build on top of an Object, which has only string keys. In order to avoid the need to convert a string key back to its native type in many situations, we store the native key value alongside the value. Thus, we only need a one-way mapping from a key type to its string form that guarantees uniqueness and equality (i.e., str(K1) === str(K2) if and only if K1 === K2).

  ##### Type:

  - Object.<string, Object>
  Source:
    - ProtoBuf.js, line 4880

#### (non-null) valueElem :ProtoBuf.Reflect.Element

  Element instance corresponding to value type.

  ##### Type:

  - ProtoBuf.Reflect.Element
  Source:
    - ProtoBuf.js, line 4864