?
u
m
/
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. Subclass super
call to the Map Map.prototype
built-in methods.This function performs the following steps when called:
If the parameter iterable is present, it is expected to be an object that implements an
The abstract operation AddEntriesFromIterable takes arguments target (an Object), iterable (an
The parameter iterable is expected to be an object that implements an
The Map
The initial value of Map.prototype
is the
This property has the attributes { [[Writable]]:
Map[@@species]
is an
The value of the
Methods that create derived collection objects should call
The Map prototype object:
This method performs the following steps when called:
The initial value of Map.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:
callbackfn should be a function that accepts three arguments. forEach
calls callbackfn once for each key/value pair present in the Map, in key insertion order. callbackfn 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 a thisArg parameter is provided, it will be used as the
callbackfn 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 to callbackfn. Each entry of a map's [[MapData]] is only visited once. New keys added after the call to forEach
begins are visited. A key will be revisited if it is deleted after it has been visited and then re-added before the forEach
call completes. Keys that are deleted after the call to forEach
begins and before being visited are not visited unless the key is added again before the forEach
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
A Map 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 arguments map (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.
The Set
extends
clause of a class definition. Subclass super
call to the Set Set.prototype
built-in methods.This function performs the following steps when called:
The Set
The initial value of Set.prototype
is the
This property has the attributes { [[Writable]]:
Set[@@species]
is an
The value of the
Methods that create derived collection objects should call
The Set prototype object:
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of Set.prototype.constructor
is
This method performs the following steps when called:
The value
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:
callbackfn should be a function that accepts three arguments. forEach
calls callbackfn once for each value present in the Set object, in value insertion order. callbackfn 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 a thisArg parameter is provided, it will be used as the
callbackfn 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.
The callbackfn is called with three arguments to be consistent with the call back functions used by forEach
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 to callbackfn.
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 the forEach
call completes. Values that are deleted after the call to forEach
begins and before being visited are not visited unless the value is added again before the forEach
call completes. New values added after the call to forEach
begins are visited.
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:
The initial value of the
The initial value of the
This property has the attributes { [[Writable]]:
Set instances are
A Set Iterator is an
The abstract operation CreateSetIterator takes arguments set (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. In Proceedings 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. Subclass super
call to the WeakMap WeakMap.prototype
built-in methods.This function performs the following steps when called:
If the parameter iterable is present, it is expected to be an object that implements an
The WeakMap
The initial value of WeakMap.prototype
is the
This property has the attributes { [[Writable]]:
The WeakMap prototype object:
The initial value of WeakMap.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. Subclass super
call to the WeakSet WeakSet.prototype
built-in methods.This function performs the following steps when called:
The WeakSet
The initial value of WeakSet.prototype
is the
This property has the attributes { [[Writable]]:
The WeakSet prototype object:
This method performs the following steps when called:
The initial value of WeakSet.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