new
Operatorsuper
Keyword? :
),
)if
Statementdo
-while
Statementwhile
Statementfor
Statementfor
-in
,for
-of
, andfor
-await
-of
Statementscontinue
Statementbreak
Statementreturn
Statementwith
Statementswitch
Statementthrow
Statementtry
Statementdebugger
Statement?
u
m
/
p
1-9
0
`
Maps are collections of key/value pairs where both the keys and values may be arbitrary
Maps must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of elements in the collection. The data structure used in this specification is only intended to describe the required observable semantics of Maps. It is not intended to be a viable implementation model.
The Map
extends
clause of a class definition. Subclasssuper
call to the MapMap.prototype
built-in methods.This function performs the following steps when called:
If the parameteriterable is present, it is expected to be an object that implements a
The abstract operation AddEntriesFromIterable takes argumentstarget (an Object),iterable (an
The parameteriterable is expected to be an object that implements a
The Map
callback should be a function that accepts two arguments.groupBy
callscallback once for each element initems, in ascending order, and constructs a new Map. Each value returned bycallback is used as a key in the Map. For each such key, the result Map has an entry whose key is that key and whose value is an array containing all the elements for whichcallback returned that key.
callback is called with two arguments: the value of the element and the index of the element.
The return value ofgroupBy
is a Map.
This function performs the following steps when called:
The initial value ofMap.prototype
is the
This property has the attributes {[[Writable]]:
Map[%Symbol.species%]
is an
The value of the
Methods that create derived collection objects should call
TheMap prototype object:
This method performs the following steps when called:
The existing[[MapData]]
The initial value ofMap.prototype.constructor
is
This method performs the following steps when called:
The value
This method performs the following steps when called:
This method performs the following steps when called:
callback should be a function that accepts three arguments.forEach
callscallback once for each key/value pair present in the Map, in key insertion order.callback is called only for keys of the Map which actually exist; it is not called for keys that have been deleted from the Map.
If athisArg parameter is provided, it will be used as the
callback is called with three arguments: the value of the item, the key of the item, and the Map being traversed.
forEach
does not directly mutate the object on which it is called but the object may be mutated by the calls tocallback. Each entry of a map's[[MapData]] is only visited once. New keys added after the call toforEach
begins are visited. A key will be revisited if it is deleted after it has been visited and then re-added before theforEach
call completes. Keys that are deleted after the call toforEach
begins and before being visited are not visited unless the key is added again before theforEach
call completes.
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
Map.prototype.size
is an
This method performs the following steps when called:
The initial value of the
The initial value of the
This property has the attributes {[[Writable]]:
Map instances are
AMap Iterator is an object that represents a specific iteration over some specific Map instance object. There is not a named
The abstract operation CreateMapIterator takes argumentsmap (an
The%MapIteratorPrototype% object:
The initial value of the
This property has the attributes {[[Writable]]:
Set objects are collections of
Set objects must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of elements in the collection. The data structure used in this specification is only intended to describe the required observable semantics of Set objects. It is not intended to be a viable implementation model.
ASet Record is a
Set Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[SetObject]] | an Object | the Set or similar object. |
[[Size]] | a non-negative | The reported size of the object. |
[[Has]] | a | Thehas method of the object. |
[[Keys]] | a | Thekeys method of the object. |
The abstract operation GetSetRecord takes argumentobj (an
The abstract operation SetDataHas takes argumentssetData (a
The abstract operation SetDataIndex takes argumentssetData (a
The abstract operation SetDataSize takes argumentsetData (a
The Set
extends
clause of a class definition. Subclasssuper
call to the SetSet.prototype
built-in methods.This function performs the following steps when called:
The Set
The initial value ofSet.prototype
is the
This property has the attributes {[[Writable]]:
Set[%Symbol.species%]
is an
The value of the
Methods that create derived collection objects should call
TheSet prototype object:
This method performs the following steps when called:
This method performs the following steps when called:
The existing[[SetData]]
The initial value ofSet.prototype.constructor
is
This method performs the following steps when called:
The value
This method performs the following steps when called:
This method performs the following steps when called:
For iteration purposes, a Set appears similar to a Map where each entry has the same value for its key and value.
This method performs the following steps when called:
callback should be a function that accepts three arguments.forEach
callscallback once for each value present in the Set object, in value insertion order.callback is called only for values of the Set which actually exist; it is not called for keys that have been deleted from the set.
If athisArg parameter is provided, it will be used as the
callback is called with three arguments: the first two arguments are a value contained in the Set. The same value is passed for both arguments. The Set object being traversed is passed as the third argument.
Thecallback is called with three arguments to be consistent with the call back functions used byforEach
methods for Map and Array. For Sets, each item value is considered to be both the key and the value.
forEach
does not directly mutate the object on which it is called but the object may be mutated by the calls tocallback.
Each value is normally visited only once. However, a value will be revisited if it is deleted after it has been visited and then re-added before theforEach
call completes. Values that are deleted after the call toforEach
begins and before being visited are not visited unless the value is added again before theforEach
call completes. New values added after the call toforEach
begins are visited.
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
For iteration purposes, a Set appears similar to a Map where each entry has the same value for its key and value.
Set.prototype.size
is an
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
The initial value of the
This property has the attributes {[[Writable]]:
Set instances are
ASet Iterator is an
The abstract operation CreateSetIterator takes argumentsset (an
The%SetIteratorPrototype% object:
The initial value of the
This property has the attributes {[[Writable]]:
WeakMaps are collections of key/value pairs where the keys are objects and/or symbols and values may be arbitrary
An implementation may impose an arbitrarily determined latency between the time a key/value pair of a WeakMap becomes inaccessible and the time when the key/value pair is removed from the WeakMap. If this latency was observable to ECMAScript program, it would be a source of indeterminacy that could impact program execution. For that reason, an ECMAScript implementation must not provide any means to observe a key of a WeakMap that does not require the observer to present the observed key.
WeakMaps must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of key/value pairs in the collection. The data structure used in this specification is only intended to describe the required observable semantics of WeakMaps. It is not intended to be a viable implementation model.
WeakMap and WeakSet are intended to provide mechanisms for dynamically associating state with an object or symbol in a manner that does not “leak” memory resources if, in the absence of the WeakMap or WeakSet instance, the object or symbol otherwise became inaccessible and subject to resource reclamation by the implementation's garbage collection mechanisms. This characteristic can be achieved by using an inverted per-object/symbol mapping of WeakMap or WeakSet instances to keys. Alternatively, each WeakMap or WeakSet instance may internally store its key and value data, but this approach requires coordination between the WeakMap or WeakSet implementation and the garbage collector. The following references describe mechanism that may be useful to implementations of WeakMap and WeakSet:
Barry Hayes. 1997. Ephemerons: a new finalization mechanism. InProceedings of the 12th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications (OOPSLA '97), A. Michael Berman (Ed.). ACM, New York, NY, USA, 176-183,http://doi.acm.org/10.1145/263698.263733.
Alexandra Barros, Roberto Ierusalimschy, Eliminating Cycles in Weak Tables. Journal of Universal Computer Science - J.UCS, vol. 14, no. 21, pp. 3481-3497, 2008,http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak
The WeakMap
extends
clause of a class definition. Subclasssuper
call to the WeakMapWeakMap.prototype
built-in methods.This function performs the following steps when called:
If the parameteriterable is present, it is expected to be an object that implements a
The WeakMap
The initial value ofWeakMap.prototype
is the
This property has the attributes {[[Writable]]:
TheWeakMap prototype object:
The initial value ofWeakMap.prototype.constructor
is
This method performs the following steps when called:
The value
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
This property has the attributes {[[Writable]]:
WeakMap instances are
WeakSets are collections of objects and/or symbols. A distinct object or symbol may only occur once as an element of a WeakSet's collection. A WeakSet may be queried to see if it contains a specific value, but no mechanism is provided for enumerating the values it holds. In certain conditions, values which are not
An implementation may impose an arbitrarily determined latency between the time a value contained in a WeakSet becomes inaccessible and the time when the value is removed from the WeakSet. If this latency was observable to ECMAScript program, it would be a source of indeterminacy that could impact program execution. For that reason, an ECMAScript implementation must not provide any means to determine if a WeakSet contains a particular value that does not require the observer to present the observed value.
WeakSets must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of elements in the collection. The data structure used in this specification is only intended to describe the required observable semantics of WeakSets. It is not intended to be a viable implementation model.
See the NOTE in
The WeakSet
extends
clause of a class definition. Subclasssuper
call to the WeakSetWeakSet.prototype
built-in methods.This function performs the following steps when called:
The WeakSet
The initial value ofWeakSet.prototype
is the
This property has the attributes {[[Writable]]:
TheWeakSet prototype object:
This method performs the following steps when called:
The initial value ofWeakSet.prototype.constructor
is
This method performs the following steps when called:
The value
This method performs the following steps when called:
The initial value of the
This property has the attributes {[[Writable]]:
WeakSet instances are
The abstract operation CanonicalizeKeyedCollectionKey takes argumentkey (an