The keys of a Map can be arbitrary values.
var map = new Map([
[ 1, 'one' ],
[ 2, 'two' ],
[ 3, 'three' ]
]);
new Map(elements)
name | type | description |
---|---|---|
elements | Array.<*> |
An optional array of key-value pairs to populate this Map with. |
The entries in this Map.
The number of key / value pairs in this Map.
Delete all entries from this Map.
This Map object.
Returns true
if the value exists within this Map. Otherwise, returns false
.
name | type | description |
---|---|---|
value | * |
The value to search for. |
true
if the value is found, otherwise false
.
Delete the specified element from this Map.
name | type | description |
---|---|---|
key | string |
The key of the element to delete from this Map. |
This Map object.
Dumps the contents of this Map to the console via console.group
.
Iterates through all entries in this Map, passing each one to the given callback.
If the callback returns false
, the iteration will break.
name | type | description |
---|---|---|
callback | EachMapCallback |
The callback which will receive the keys and entries held in this Map. |
This Map object.
Returns the value associated to the key
, or undefined
if there is none.
name | type | description |
---|---|---|
key | string |
The key of the element to return from the |
The element associated with the specified key or undefined
if the key can't be found in this Map object.
Returns an Array
of all the values stored in this Map.
An array of the values stored in this Map.
Returns a boolean indicating whether an element with the specified key exists or not.
name | type | description |
---|---|---|
key | string |
The key of the element to test for presence of in this Map. |
Returns true
if an element with the specified key exists in this Map, otherwise false
.
Returns all entries keys in this Map.
Array containing entries' keys.
Merges all new keys from the given Map into this one.
If it encounters a key that already exists it will be skipped unless override is set to true
.
name | type | arguments | Default | description |
---|---|---|---|---|
map | Phaser.Structs.Map |
The Map to merge in to this Map. |
||
override | boolean | <optional> | false |
Set to |
This Map object.
Adds an element with a specified key
and value
to this Map.
If the key
already exists, the value will be replaced.
If you wish to add multiple elements in a single call, use the setAll
method instead.
name | type | description |
---|---|---|
key | string |
The key of the element to be added to this Map. |
value | * |
The value of the element to be added to this Map. |
This Map object.
Adds all the elements in the given array to this Map.
If the element already exists, the value will be skipped.
name | type | description |
---|---|---|
elements | Array.<*> |
An array of key-value pairs to populate this Map with. |
This Map object.
Returns an Array
of all entries.
An Array
of entries.