Search completed in 1.16 seconds.
Iterators and generators - JavaScript
<< PreviousNext >> Processing each of the items in a collection is a very common operation. JavaScript provides a number of ways of iterating over a collection, from simple for loops to map() and filter().
Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of for...of loops. ...
...very common operation. JavaScript provides a number of ways of iterating over a collection, from simple for loops to map() and filter().
Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of for...of loops. For details, see also: Iteration_protocols for...of function* and Generator yield and yield*
Iterators In JavaScript an
iterator is an object which defines a sequence and potentially a return value upon its termination. Specifically, an
iterator is any object which implements the
Iterator protocol by having a next() method that returns an object with two properties: value The next value in the iteration sequence. done This is true if the last value in the sequence has already been consume...
...efines a sequence and potentially a return value upon its termination. Specifically, an
iterator is any object which implements the
Iterator protocol by having a next() method that returns an object with two properties: value The next value in the iteration sequence. done This is true if the last value in the sequence has already been consumed. If value is present alongside done, it is the
iterator's return value. Once created, an
iterator object can be iterated explicitly by repeatedly calling next(). Iterating over an
iterator is said to consume the
iterator, because it is generally only possible to do once. ...
...And 14 more matches
NodeIterator - Web APIs
Non-matching nodes are skipped, but their children may be included, if relevant. ...
...Non-matching nodes are skipped, but their children may be included, if relevant. ...
...Non-matching nodes are skipped, but their children may be included, if relevant. ...
...And 13 more matches
Array.prototype[@@iterator]() - JavaScript
The @@
iterator method is part of The iterable protocol, that defines how to synchronously iterate over a sequence of values. The initial value of the @@
iterator property is the same function object as the initial value of the values() property. Syntax arr[Symbol.
iterator]() Return value The initial value given by the values()
iterator. By default, using arr[Symbol.
iterator] will return the values() function. ...
...rator property is the same function object as the initial value of the values() property. Syntax arr[Symbol.
iterator]() Return value The initial value given by the values()
iterator. By default, using arr[Symbol.
iterator] will return the values() function. ...
...If you have a funct...
...And 8 more matches
Iterator - Archive of obsolete content
Non-standard. The
Iterator function is a SpiderMonkey-specific feature, and will be removed at some point. For future-facing usages, consider using for..of loops and the
iterator protocol. The
Iterator function returns an object which implements legacy
iterator protocol and iterates over enumerable properties of an object. Syntax
Iterator(object, [keyOnly]) Parameters object Object to iterate over properties. keyOnly If keyOnly is truthy value,
Iterator.prototype.next returns property_name only. Description Returns
Iterator instance that iterates over object.
Iterator instance returns [property_name, property_value] array for each iteration if keyOnly is falsy, otherwise, if keyOnly is truthy, it returns property_name for each iteration. ...
...ject Object to iterate over properties. keyOnly If keyOnly is truthy value,
Iterator.prototype.next returns property_name only. Description Returns
Iterator instance that iterates over object.
Iterator instance returns [property_name, property_value] array for each iteration if keyOnly is falsy, otherwise, if keyOnly is truthy, it returns property_name for each iteration. If object is the
Iterator instance or Generator instance, it returns object itself. Properties
Iterator.prototype[@@
iterator] Returns a function that returns
iterator object. Methods
Iterator.prototype.next Returns next item in the [property_name, property_value] format or property_name only. It throws StopIteration if there are no more items. Examples Iterating over properties of an object var a = { x: 1...
...tance, it returns object itself. Properties
Iterator.prototype[@@
iterator] Returns a function that returns
iterator object. Methods
Iterator.prototype.next Returns next item in the [property_name, property_value] format or property_name only. It throws StopIteration if there are no more items. ...
...And 5 more matches
NodeIterator.whatToShow - Web APIs
The Node
Iterator.whatToShow read-only property represents an unsigned integer representing a bitmask signifying what types of nodes should be returned by the Node
Iterator. Syntax var nodeTypes = node
Iterator.whatToShow; The values that can be combined to form the bitmask are: Constant Numerical value Description NodeFilter.SHOW_ALL -1 (that is the max value of unsigned long) Shows all nodes. NodeFilter.SHOW_ATTRIBUTE 2 Shows attribute Attr nodes. This is meaningful only when creating a Node
Iterator or TreeWalker with an Attr node as its root; in this case, it means that the attribute node will appear in the first position of the iteration or traversal. Since attributes are never children of other nodes, they do not appear when traversing over th...
...odes. NodeFilter.SHOW_DOCUMENT 256 Shows Document nodes. NodeFilter.SHOW_DOCUMENT_FRAGMENT 1024 Shows DocumentFragment nodes. NodeFilter.SHOW_DOCUMENT_TYPE 512 Shows DocumentType nodes. NodeFilter.SHOW_ELEMENT 1 Shows Element nodes. NodeFilter.SHOW_ENTITY 32 Shows Entity nodes. This is meaningful only when creating a Node
Iterator or TreeWalker with an Entity node as its root; in this case, it means that the Entity node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree. NodeFilter.SHOW_ENTITY_REFERENCE 16 Shows EntityReference nodes. NodeFilter.SHOW_NOTATION 2048 Shows Notation nod...
...in this case, it means that the Entity node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree. NodeFilter.SHOW_ENTITY_REFERENCE 16 Shows EntityReference nodes. NodeFilter.SHOW_NOTATION 2048 Shows Notation nodes. This is meaningful only when creating a Node
Iterator or TreeWalker with a Notation node as its root; in this case, it means that the Notation node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree. NodeFilter.SHOW_PROCESSING_INSTRUCTION 64 Shows ProcessingInstruction nodes. NodeFilter.SHOW_TEXT 4 Shows Text nod...
...And 4 more matches
Symbol.iterator - JavaScript
The well-known Symbol.
iterator symbol specifies the default
iterator for an object. Used by for...of. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Description Whenever an object needs to be iterated (such as at the beginning of a for..of loop), its @@
iterator method is called with no arguments, and the returned
iterator is used to obtain the values to be iterated. Some built-in types have a default iteration behavior, while other types (such as Object) do not. ...
...n/interactive-examples and send us a pull request. Description Whenever an object needs to be iterated (such as at the beginning of a for..of loop), its @@
iterator method is called with no arguments, and the returned
iterator is used to obtain the values to be iterated. Some built-in types have a default iteration behavior, while other types (such as Object) do not. The built-in types with a @@
iterator method are: Array.prototype[@@
iterator]() TypedArray.prototype[@@
iterator]() String.prototype[@@
iterator]() Map.prototype[@@
iterator]() Set.prototype[@@
iterator]() See also Iteration protocols for more information. ...
...built-in types have a default iteration behavior, while other types (such as Object) do not. The built-in types with a @@
iterator method are: Array.prototype[@@
iterator]() TypedArray.prototype[@@
iterator]() String.prototype[@@
iterator]() Map.prototype[@@
iterator]() Set.prototype[@@
iterator]() See also Iteration protocols for more information. ...
...And 4 more matches
NodeIterator.previousNode() - Web APIs
The Node
Iterator.previousNode() method returns the previous node in the set represented by the Node
Iterator and moves the position of the
iterator backwards within the set. This method returns null when the current node is the first node in the set. In old browsers, as specified in old versions of the specifications, the method may throws the INVALID_STATE_ERR DOMException if this method is called after the Node
Iterator.detach()method. Recent browsers never throw. ...
...the Node
Iterator and moves the position of the
iterator backwards within the set. This method returns null when the current node is the first node in the set. In old browsers, as specified in old versions of the specifications, the method may throws the INVALID_STATE_ERR DOMException if this method is called after the Node
Iterator.detach()method. Recent browsers never throw. ...
...he
iterator backwards within the set. This method returns null when the current node is the first node in the set. In old browsers, as specified in old versions of the specifications, the method may throws the INVALID_STATE_ERR DOMException if this method is called after the Node
Iterator.detach()method. Recent browsers never throw. ...
...And 3 more matches
JS_ContextIterator
Obsolete since JSAPI 52This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. Cycles through the JS contexts associated with a particular JSRuntime. Syntax JSContext * JS_Context
Iterator(JSRuntime *rt, JSContext **iterp); Name Type Description rt JSRuntime * The runtime to walk. iterp JSContext * In-out parameter. ...
...SContext * JS_Context
Iterator(JSRuntime *rt, JSContext **iterp); Name Type Description rt JSRuntime * The runtime to walk. iterp JSContext * In-out parameter. On input, *iterp must be NULL or point to a context in rt. On success, the value of *iterp is modified so that repeated calls cycle through all the contexts in rt. Description JS_Context
Iterator steps through the set of contexts associated with the runtime rt. Each call to JS_Context
Iterator returns the next context in the cycle. iterp must point to a variable of type JSContext *. If *iterp is NULL, JS_Context
Iterator modifies it to point to the first JSContext in the list. ...
...rt. Description JS_Context
Iterator steps through the set of contexts associated with the runtime rt. Each call to JS_Context
Iterator returns the next context in the cycle. iterp must point to a variable of type JSContext *. If *iterp is NULL, JS_Context
Iterator modifies it to point to the first JSContext in the list. Otherwise *iterp must point to an existing context in rt, and JS_Context
Iterator modifies it to point to the next context in the list, if any, and NULL otherwise. JS_Context
Iterator returns the new value of *iterp. ...
...And 2 more matches
NodeIterator.detach() - Web APIs
The Node
Iterator.detach() method is a no-op, kept for backward compatibility only. Originally, it detached the Node
Iterator from the set over which it iterates, releasing any resources used by the set and setting the
iterator's state to INVALID. Once this method had been called, calls to other methods on Node
Iterator would raise the INVALID_STATE_ERR exception. ...
... The Node
Iterator.detach() method is a no-op, kept for backward compatibility only. Originally, it detached the Node
Iterator from the set over which it iterates, releasing any resources used by the set and setting the
iterator's state to INVALID. Once this method had been called, calls to other methods on Node
Iterator would raise the INVALID_STATE_ERR exception. ...
...detach() method is a no-op, kept for backward compatibility only. Originally, it detached the Node
Iterator from the set over which it iterates, releasing any resources used by the set and setting the
iterator's state to INVALID. Once this method had been called, calls to other methods on Node
Iterator would raise the INVALID_STATE_ERR exception. ...
...And 2 more matches
NodeIterator.nextNode() - Web APIs
The Node
Iterator.nextNode() method returns the next node in the set represented by the Node
Iterator and advances the position of the
iterator within the set. The first call to nextNode() returns the first node in the set. This method returns null when there are no nodes left in the set. In old browsers, as specified in old versions of the specifications, the method may throws the INVALID_STATE_ERR DOMException if this method is called after the Node
Iterator.detach()method. Recent browsers never throw. ...
...he
iterator within the set. The first call to nextNode() returns the first node in the set. This method returns null when there are no nodes left in the set. In old browsers, as specified in old versions of the specifications, the method may throws the INVALID_STATE_ERR DOMException if this method is called after the Node
Iterator.detach()method. Recent browsers never throw. ...
...all to nextNode() returns the first node in the set. This method returns null when there are no nodes left in the set. In old browsers, as specified in old versions of the specifications, the method may throws the INVALID_STATE_ERR DOMException if this method is called after the Node
Iterator.detach()method. Recent browsers never throw. ...
...And 2 more matches
Map.prototype[@@iterator]() - JavaScript
The initial value of the @@
iterator property is the same function object as the initial value of the entries method. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap[Symbol.
iterator] Return value The map
iterator function, which is the entries() function by default. ...
...itial value of the entries method. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap[Symbol.
iterator] Return value The map
iterator function, which is the entries() function by default. ...
...ontribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap[Symbol.
iterator] Return value The map
iterator function, which is the entries() function by default. ...
...And 2 more matches
Symbol.asyncIterator - JavaScript
The Symbol.async
Iterator well-known symbol specifies the default Async
Iterator for an object. If this property is set on an object, it is an async iterable and can be used in a for await...of loop. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Description The Symbol.async
Iterator symbol is a builtin symbol that is used to access an object's @@async
Iterator method. In order for an object to be async iterable, it must have a Symbol.async
Iterator key. ...
...e to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Description The Symbol.async
Iterator symbol is a builtin symbol that is used to access an object's @@async
Iterator method. In order for an object to be async iterable, it must have a Symbol.async
Iterator key. ...
...@async
Iterator method. In order for an object to be async iterable, it must have a Symbol.async
Iterator key. Property attributes of Symbol.async
Iterator Writable no Enumerable no Configurable no Examples User-defined Async Iterables You can define your own async iterable by setting the [Symbol.async
Iterator] property on an object. ...
...And 2 more matches
NodeIterator.expandEntityReferences - Web APIs
The Node
Iterator.expandEntityReferences read-only property returns a Boolean flag indicating whether or not the children of entity reference nodes are visible to the Node
Iterator. If this value is false, the children of entity reference nodes (as well as all of their descendants) are rejected. This takes precedence over the value of the Node
Iterator.whatToShow method and the associated filter. ...
...ndEntityReferences read-only property returns a Boolean flag indicating whether or not the children of entity reference nodes are visible to the Node
Iterator. If this value is false, the children of entity reference nodes (as well as all of their descendants) are rejected. This takes precedence over the value of the Node
Iterator.whatToShow method and the associated filter. ...
...ean flag indicating whether or not the children of entity reference nodes are visible to the Node
Iterator. If this value is false, the children of entity reference nodes (as well as all of their descendants) are rejected. This takes precedence over the value of the Node
Iterator.whatToShow method and the associated filter. ...
... not the children of entity reference nodes are visible to the Node
Iterator. If this value is false, the children of entity reference nodes (as well as all of their descendants) are rejected. This takes precedence over the value of the Node
Iterator.whatToShow method and the associated filter. Syntax expand = node
Iterator.expandEntityReferences; Example var node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); expand = node
Iterator.expandEntityReferences; Specifications Specification Status Comment Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Node
Iterator.expandEntityReferences' in that specification. ...
Set.prototype[@@iterator]() - JavaScript
The initial value of the @@
iterator property is the same function object as the initial value of the values property. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax mySet[Symbol.
iterator] Return value The Set
iterator function, which is the values() function by default. ...
...itial value of the values property. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax mySet[Symbol.
iterator] Return value The Set
iterator function, which is the values() function by default. ...
...If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax mySet[Symbol.
iterator] Return value The Set
iterator function, which is the values() function by default. ...
...yntax mySet[Symbol.
iterator] Return value The Set
iterator function, which is the values() function by default. Examples Using [@@
iterator]() const mySet = new Set(); mySet.add('0'); mySet.add(1); mySet.add({}); const setIter = mySet[Symbol.
iterator](); console.log(setIter.next().value); // "0" console.log(setIter.next().value); // 1 console.log(setIter.next().value); // Object Using [@@
iterator]() with for..of const mySet = new Set(); mySet.add('0'); mySet.add(1); mySet.add({}); for (const v of mySet) { console.log(v); } Specifications Specification ECMAScript (ECMA-262)The definition of 'Set.prototype[@@
iterator]' in that specification. ...
String.prototype[@@iterator]() - JavaScript
The [@@
iterator]() method returns a new
Iterator object that iterates over the code points of a String value, returning each code point as a String value. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax str[Symbol.
iterator] Return value A new
Iterator object. ...
...over the code points of a String value, returning each code point as a String value. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax str[Symbol.
iterator] Return value A new
Iterator object. ...
...as a String value. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax str[Symbol.
iterator] Return value A new
Iterator object. ...
...ute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax str[Symbol.
iterator] Return value A new
Iterator object. Examples Using [@@
iterator]() var str = 'A\uD835\uDC68'; var strIter = str[Symbol.
iterator](); console.log(strIter.next().value); // "A" console.log(strIter.next().value); // "\uD835\uDC68" Using [@@
iterator]() with for..of var str = 'A\uD835\uDC68B\uD835\uDC69C\uD835\uDC6A'; for (var v of str) { console.log(v); } // "A" // "\uD835\uDC68" // "B" // "\uD835\uDC69" // "C" // "\uD835\uDC6A" Specifications Specification ECMAScript (ECMA-262)The definition of 'String.prototype[@@
iterator]()' in that specification. ...
Document.createNodeIterator() - Web APIs
whatToShow Optional Is an optional unsigned long representing a bitmask created by combining the constant properties of NodeFilter. It is a convenient way of filtering for certain types of node. It defaults to 0xFFFFFFFF representing the SHOW_ALL constant. Constant Numerical value Description NodeFilter.SHOW_ALL -1 (that is the max value of unsigned long) Shows all nodes. NodeFilter.SHOW_ATTRIBUTE 2 Shows attribute Attr nodes. ...
...odeFilter.FILTER_REJECT, or NodeFilter.FILTER_SKIP. See the Example. Note: Prior to Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9), this method accepted an optional fourth parameter (entityReferenceExpansion) that is not part of the DOM4 specification, and has therefore been removed. This parameter indicated whether or not the children of entity reference nodes were visible to the
iterator. Since such nodes were never created in browsers, this paramater had no effect. Example const node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode(node) { return node.nodeName.toLowerCase() === 'p' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; } } ); const pars = []; let currentNode; while (currentNode = n...
...ince such nodes were never created in browsers, this paramater had no effect. Example const node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode(node) { return node.nodeName.toLowerCase() === 'p' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; } } ); const pars = []; let currentNode; while (currentNode = node
Iterator.nextNode()) { pars.push(currentNode); } Specifications Specification Status Comment DOMThe definition of 'document.createNode
Iterator' in that specification. Living Standard ...
NodeIterator.filter - Web APIs
The Node
Iterator.filter read-only method returns a NodeFilter object, that is an object implement an acceptNode(node) method, used to screen nodes. When creating the Node
Iterator, the filter object is passed in as the third parameter, and the object method acceptNode(node) is called on every single node to determine whether or not to accept it. This function should return the constant NodeFilter.FILTER_ACCEPT for cases when the node should be accepted and NodeFilter.FILTER_REJECT for cases when the node should be rejected. ...
...eating the Node
Iterator, the filter object is passed in as the third parameter, and the object method acceptNode(node) is called on every single node to determine whether or not to accept it. This function should return the constant NodeFilter.FILTER_ACCEPT for cases when the node should be accepted and NodeFilter.FILTER_REJECT for cases when the node should be rejected. Syntax nodeFilter = node
Iterator.filter; Example const node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); nodeFilter = node
Iterator.filter; Specifications Specification Status Comment DOMThe definition of 'Node
Iterator.filter' in that specification. Living Standard ...
... }, false ); nodeFilter = node
Iterator.filter; Specifications Specification Status Comment DOMThe definition of 'Node
Iterator.filter' in that specification. Living Standard No change from Document Object Model (DOM) Level 2 Traversal and Range Specification. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Node
Iterator.filter' in that specification. Obsolete Initial definition. ...
XPathResult.invalidIteratorState - Web APIs
The read-only invalid
IteratorState property of the XPathResult interface signifies that the
iterator has become invalid. It is true if XPathResult.resultType is UNORDERED_NODE_
ITERATOR_TYPE or ORDERED_NODE_
ITERATOR_TYPE and the document has been modified since this result was returned. Note: This feature is available in Web Workers. Syntax var
iteratorState = result.invalid
IteratorState; Return value A boolean value indicating whether the
iterator has become invalid. Example The following example shows the use of the invalid
IteratorState property. ...
...RED_NODE_
ITERATOR_TYPE and the document has been modified since this result was returned. Note: This feature is available in Web Workers. Syntax var
iteratorState = result.invalid
IteratorState; Return value A boolean value indicating whether the
iterator has become invalid. Example The following example shows the use of the invalid
IteratorState property. ...
...invalid
IteratorState; Return value A boolean value indicating whether the
iterator has become invalid. Example The following example shows the use of the invalid
IteratorState property. HTML <div>XPath example</div> <p>
Iterator state: <output></output></p> JavaScript var xpath = "//div"; var result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null); // Invalidates the
iterator state document.querySelector("div").remove(); document.querySelector("output").textContent = result.invalid
IteratorState ? "invalid" : "valid"; Result Specifications Specification Status Comment Document Object Model (DOM) Level 3 XPath SpecificationThe definition of 'XPathResult.invalid
IteratorState' in that specification. Recommendation Initial definition ...
The legacy Iterator protocol - JavaScript
Non-standard. The legacy
iterator protocol was a SpiderMonkey-specific feature, which is removed in Firefox 58+. For future-facing usages, consider using for..of loops and the
iterator protocol. The deprecated Firefox-only
iterator protocol Firefox, prior to version 26 implemented another
iterator protocol that is similar to the standard ES2015
Iterator protocol. An object is an legacy
iterator when it implements a next() method with the following semantics, and throws StopIteration at the end of iteration. Property Value next A zero arguments function that returns an value. ...
...ior to version 26 implemented another
iterator protocol that is similar to the standard ES2015
Iterator protocol. An object is an legacy
iterator when it implements a next() method with the following semantics, and throws StopIteration at the end of iteration. Property Value next A zero arguments function that returns an value. Difference between legacy and ES2015
iterator protocols The value was returned directly as a return value of calls to next, instead of the value property of a placeholder object Iteration termination was expressed by throwing a StopIteration object. Simple example with the old protocol function make
Iterator(array){ var nextIndex = 0; return { next: function(){ if(nextIndex < array.length){ ret...
...f a placeholder object Iteration termination was expressed by throwing a StopIteration object. ...
JSIteratorOp
Obsolete since JSAPI 26This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. This article covers features introduced in SpiderMonkey 1.8 Callback for creating
iterators. Syntax typedef JSObject * (*JS
IteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly); Name Type Description cx JSContext * Pointer to the JS context in which the
iterator creation should take place. ...
...erMonkey 1.8 Callback for creating
iterators. Syntax typedef JSObject * (*JS
IteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly); Name Type Description cx JSContext * Pointer to the JS context in which the
iterator creation should take place. obj JSObject * Pointer to the object to iterate over. keysonly JSBool If true, the
iterator should yield keys only, not [key, value] pairs. Description The JavaScript engine calls the JSExtendedClass.
iteratorObject callback to create an
iterator object for a given object. The callback should return an
iterator object or NULL if an error or exception occurred on cx. See Also bug 909178 ...
JS_NewPropertyIterator
Syntax JSObject * JS_NewProperty
Iterator(JSContext *cx, JS::Handle<JSObject*> obj); Name Type Description cx JSContext * The JS context in which to enumerate properties. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. ...
...ext. obj JS::Handle<JSObject*> The object whose properties are to be enumerated. Description Create an object to iterate over the enumerable own properties of obj, in arbitrary order. (This differs from longstanding for..in loop order, which uses the order in which obj's properties were defined. Note also that while for..in includes properties inherited from prototypes,
iterator objects do not.) On success, this returns an
iterator object that can be passed to JS_NextProperty to fetch the property ids. On error, it returns NULL. The
iterator object created by this function is not a JavaScript
Iterator. It is an opaque object with no properties visible from JavaScript. See Also bug 1081660 ...
TypedArray.prototype[@@iterator]() - JavaScript
The initial value of the @@
iterator property is the same function object as the initial value of the values property. Syntax arr[Symbol.
iterator]() Return value The array
iterator function, which is the values() function by default. ...
...]() Return value The array
iterator function, which is the values() function by default. Examples Iteration using for...of loop var arr = new Uint8Array([10, 20, 30, 40, 50]); // your browser must support for..of loop // and let-scoped variables in for loops for (let n of arr) { console.log(n); } Alternative iteration var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArr = arr[Symbol.
iterator](); console.log(eArr.next().value); // 10 console.log(eArr.next().value); // 20 console.log(eArr.next().value); // 30 console.log(eArr.next().value); // 40 console.log(eArr.next().value); // 50 Specifications Specification ECMAScript (ECMA-262)The definition of '%TypedArray%.prototype[@@
iterator]()' in that specification. ...
nsIDirectoryIterator
xpcom/obsolete/nsIFileSpec.idlScriptable Please add a summary to this article. ...
NodeIterator.pointerBeforeReferenceNode - Web APIs
The Node
Iterator.pointerBeforeReferenceNode read-only property returns a Boolean flag that indicates whether the NodeFilter is anchored before (if this value is true) or after (if this value is false) the anchor node indicated by the Node
Iterator.referenceNode property. Syntax flag = node
Iterator.pointerBeforeReferenceNode; Example var node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); flag = node
Iterator.pointerBeforeReferenceNode; Specifications Specification Status Comment DOMThe definition of 'Node
Iterator.pointerBeforeReferenceNode' in that specification. Living Standard Initial definition. ...
NodeIterator.referenceNode - Web APIs
The Node
Iterator.referenceNode read-only returns the Node to which the
iterator is anchored; as new nodes are inserted, the
iterator remains anchored to the reference node as specified by this property. Syntax node = node
Iterator.referenceNode; Example var node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); node = node
Iterator.referenceNode; Specifications Specification Status Comment DOMThe definition of 'Node
Iterator.referenceNode' in that specification. Living Standard Initial definition. ...
NodeIterator.root - Web APIs
The Node
Iterator.root read-only property represents the Node that is the root of what the Node
Iterator traverses. Syntax root = node
Iterator.root; Example var node
Iterator = document.createNode
Iterator( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); root = node
Iterator.root; // document.body in this case Specifications Specification Status Comment DOMThe definition of 'Node
Iterator.root' in that specification. Living Standard No change from Document Object Model (DOM) Level 2 Traversal and Range Specification. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Node
Iterator.root' in that specification. Obsolete Initial defi...
arguments[@@iterator]() - JavaScript
The initial value of the @@
iterator property is the same function object as the initial value of the Array.prototype.values property. Syntax arguments[Symbol.
iterator]() Examples Iteration using for...of loop function f() { // your browser must support for..of loop // and let-scoped variables in for loops for (let letter of arguments) { console.log(letter); } } f('w', 'y', 'k', 'o', 'p'); Specifications Specification ECMAScript (ECMA-262)The definition of 'CreateUnmappedArgumentsObject' in that specification. ECMAScript (ECMA-262)The definition of 'CreateMappedArgumentsObject' in that specification. ...
Index - Web APIs
dini, Method, NeedsExample, Reference, forEach() The CSSUnparsedValue.forEach() method executes a provided function once for each element of the CSSUnparsedValue. 489 CSSUnparsedValue.keys() API, CSS Typed Object Model API, CSSUnparsedValue, Constructor, Experimental, Houdini, Method, NeedsExample, Reference, keys() The CSSUnparsedValue.keys() method returns a new Array
Iterator object that contains the keys for each index in the array. 490 CSSUnparsedValue.length API, CSS Typed Object Model API, CSSUnparsedValue, Constructor, Experimental, Houdini, NeedsExample, Property, Reference, length The length read-only property of the CSSUnparsedValue interface returns the number of items in the object. 491 CSSUnparsedValue.values() API, CSS T...
...oudini, NeedsExample, Property, Reference, length The length read-only property of the CSSUnparsedValue interface returns the number of items in the object. 491 CSSUnparsedValue.values() API, CSS Typed Object Model API, CSSUnparsedValue, Constructor, Experimental, Houdini, Method, NeedsExample, Reference, values() The CSSUnparsedValue.values() method returns a new Array
Iterator object that contains the values for each index in the CSSUnparsedValue object. 492 CSSValue API, CSSValue, DOM, Interface, NeedsExample, Reference The CSSValue interface represents the current computed value of a CSS property. 493 CSSValue.cssText API, CSSValue, Property, Reference, cssText The cssText property of the CSSValue interface represents the cur...
...the list. 769 DOMTokenList.contains() API, Contains, DOM, DOMTokenList, Method, Reference The contains() method of the DOMTokenList interface returns a Boolean -- true if the underlying list contains the given token, otherwise false. 770 DOMTokenList.entries() DOM, DOMTokenList, Iterable, Method, Reference, Web The DOMTokenList.entries() method returns an
iterator allowing you to go through all key/value pairs contained in this object. The values are DOMString objects, each representing a single token. 771 DOMTokenList.forEach() DOM, DOMTokenList, Iterable, Method, Reference, Web, forEach The forEach() method of the DOMTokenList interface calls the callback given in parameter once for each value pair in the list, in insertion order. ...
...And 33 more matches
Iteration protocols - JavaScript
As a couple of additions to ECMAScript 2015, Iteration protocols aren't new built-ins or syntax, but protocols. These protocols can be implemented by any object by simply following some conventions. There are two protocols: The iterable protocol and the
iterator protocol. The iterable protocol The iterable protocol allows JavaScript objects to define or customize their iteration behavior, such as what values are looped over in a for...of construct. ...
...erator protocol. The iterable protocol The iterable protocol allows JavaScript objects to define or customize their iteration behavior, such as what values are looped over in a for...of construct. Some built-in types are built-in iterables with a default iteration behavior, such as Array or Map, while other types (such as Object) are not. In order to be iterable, an object must implement the @@
iterator method, meaning that the object (or one of the objects up its prototype chain) must have a property with a @@
iterator key which is available via constant Symbol.
iterator: Property Value [Symbol.
iterator] A zero-argument function that returns an object, conforming to the
iterator protocol. Whenever an object needs to be iterated (such as at the beginning of a fo...
... Note that when this zero-argument function is called, it is invoked as a method on the iterable object. ...
...And 26 more matches
Array.from() - JavaScript
Error have their original values and that callback.call() evaluates to the original value of Function.prototype.call()). In addition, since true iterables cannot be polyfilled, this implementation does not support generic iterables as defined in the 6th Edition of ECMA-262. ...
...callback.call() evaluates to the original value of Function.prototype.call()). In addition, since true iterables cannot be polyfilled, this implementation does not support generic iterables as defined in the 6th Edition of ECMA-262. ...
...aluates to the original value of Function.prototype.call()). In addition, since true iterables cannot be polyfilled, this implementation does not support generic iterables as defined in the 6th Edition of ECMA-262. ...
...And 23 more matches
Array.prototype.values() - JavaScript
Syntax arr.values() Return value A new Array
iterator object. Examples Iteration using for...of loop var arr = ['a', 'b', 'c', 'd', 'e']; var
iterator = arr.values(); for (let letter of
iterator) { console.log(letter); } //"a" "b" "c" "d" "e" Array.prototype.values is default implementation of Array.prototype[Symbol.
iterator]. ...
...rator object that contains the values for each index in the array. Syntax arr.values() Return value A new Array
iterator object. Examples Iteration using for...of loop var arr = ['a', 'b', 'c', 'd', 'e']; var
iterator = arr.values(); for (let letter of
iterator) { console.log(letter); } //"a" "b" "c" "d" "e" Array.prototype.values is default implementation of Array.prototype[Symbol.
iterator]. ...
...ray. Syntax arr.values() Return value A new Array
iterator object. Examples Iteration using for...of loop var arr = ['a', 'b', 'c', 'd', 'e']; var
iterator = arr.values(); for (let letter of
iterator) { console.log(letter); } //"a" "b" "c" "d" "e" Array.prototype.values is default implementation of Array.prototype[Symbol.
iterator]. ...
...And 10 more matches
Introduction to using XPath in JavaScript - XPath
following code will not work: var paragraphCount = document.evaluate('count(//p)', document, null, XPathResult.ANY_TYPE, null ); alert( 'This document contains ' + paragraphCount.stringValue + ' paragraph elements' ); Instead, it will return an exception with the code NS_DOM_TYPE_ERROR. Node-Set Types The XPathResult object allows node-sets to be returned in 3 principal different types:
Iterators Snapshots First Nodes
Iterators When the specified result type in the resultType parameter is either: UNORDERED_NODE_
ITERATOR_TYPE ORDERED_NODE_
ITERATOR_TYPE The XPathResult object returned is a node-set of matched nodes which will behave as an
iterator, allowing us to access the individual nodes contained by using the iterateNext() method of the XPathResult. Once we have iterated ov...
...matched nodes which will behave as an
iterator, allowing us to access the individual nodes contained by using the iterateNext() method of the XPathResult. Once we have iterated over all of the individual matched nodes, iterateNext() will return null. ...
... iterateNext() method of the XPathResult. Once we have iterated over all of the individual matched nodes, iterateNext() will return null. Note however, that if the document is mutated (the document tree is modified) between iterations that will invalidate the iteration and the invalid
IteratorState property of XPathResult is set to true, and a NS_ERROR_DOM_INVALID_STATE_ERR exception is thrown. ...
...And 10 more matches
yield* - JavaScript
to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax yield* expression; expression The expression which returns an iterable object. Description The yield* expression iterates over the operand and yields each value returned by it. ...
... The value of yield* expression itself is the value returned by that
iterator when it's closed (i.e., when done is true). Examples Delegating to another generator In following code, values yielded by g1() are returned from next() calls just like those which are yielded by g2(). ...
...on itself is the value returned by that
iterator when it's closed (i.e., when done is true). Examples Delegating to another generator In following code, values yielded by g1() are returned from next() calls just like those which are yielded by g2(). ...
...And 8 more matches
Bytecode Descriptions
ements: MakeConstructor, step 8, when writablePrototype is false. Format: JOF_ATOM, JOF_PROP, JOF_PROPINIT, JOF_IC InitElem, InitHiddenElem Stack: obj, id, val => obj Define a data property on obj with property key id and value val. obj must be an object. Implements: CreateDataPropertyOrThrow. This instruction is used for object literals like {0: val} and {[id]: val}, and methods like *[Symbol.
iterator]() {}. JSOp::InitHiddenElem is the same but defines a non-enumerable property, for class methods. Format: JOF_ELEM, JOF_PROPINIT, JOF_IC InitPropGetter, InitHiddenPropGetter Operands: (uint32_t nameIndex) Stack: obj, getter => obj Define an accessor property on obj with the given getter. nameIndex gives the property name. obj must be an object and getter must be a function. JSOp::InitHiddenPro...
...reated by super[key] in non-strict code. The receiver is this and obj is the SuperBase of the enclosing method. Format: JOF_ELEM, JOF_PROPSET, JOF_CHECKSLOPPY StrictSetElemSuper Stack: receiver, key, obj, val => val Like JSOp::SetElemSuper, but for strict mode code. Format: JOF_ELEM, JOF_PROPSET, JOF_CHECKSTRICT Enumeration Iter Stack: val => iter Set up a for-in loop by pushing a Property
IteratorObject over the enumerable properties of val. Implements: ForIn/OfHeadEvaluation step 6, EnumerateObjectProperties. (The spec refers to an "
Iterator object" with a next method, but notes that it "is never directly accessible" to scripts. The object we use for this has no public methods.) If val is null or undefined, this pushes an empty
iterator. The iter object pushed by this instruction must not...
...pically a single try note entry marks the contiguous chunk of bytecode from the instruction after JSOp::Iter to JSOp::EndIter (inclusive); but if that range contains any instructions on exit slides, after a JSOp::EndIter, then those must be correctly noted as outside the loop. Format: JOF_IC MoreIter Stack: iter => iter, name Get the next property name for a for-in loop. iter must be a Property
IteratorObject produced by JSOp::Iter. This pushes the property name for the next loop iteration, or MagicValue(JS_NO_ITER_VALUE) if there are no more enumerable properties to iterate over. The magic value must be used only by JSOp::IsNoIter and JSOp::EndIter. IsNoIter Stack: val => val, done Test whether the value on top of the stack is MagicValue(JS_NO_ITER_VALUE) and push the boolean result. Iter...
...And 7 more matches
Mozilla internal string guide
for you. nsSubstringTuple - created via string concatenation nsDependentSubstring - created through Substring nsPromiseFlatString - created through PromiseFlatString() nsLiteral[C]String - created through the ""_ns and u""_ns user-defined literals Of course, there are times when it is necessary to reference these string classes in your code, but as a general rule they should be avoided. ...
...e dereferenced. Writing to a mutable string is also simple: /** * Replace every tab character in `data` with a space. */ void ReplaceTabs(nsAString& data) { char16_t* cur = data.BeginWriting(); char16_t* end = data.EndWriting(); for (; cur < end; ++cur) { if (char16_t('\t') == *cur) *cur = char16_t(' '); } } You may change the length of a string via SetLength(). Note that
Iterators become invalid after changing the length of a string: /** * Replace every tab character in `data` with four spaces. */ void ReplaceTabs2(nsAString& data) { int len = data.Length(); char16_t *cur = data.BeginWriting(); char16_t *end = data.EndWriting(); // Because `cur` may change during the loop, track the position // within the string. int pos = 0; while (cur < end) { if ...
...er Classes and Functions Converting Cocoa strings Use mozilla::CopyCocoaStringToXPCOMString() in mozilla/MacStringHelpers.h to convert Cocoa strings to XPCOM strings. Searching strings - looking for substrings, characters, etc. FindInReadable() is the replacement for the old string.Find(..). The syntax is: PRBool FindInReadable(const nsAString& pattern, nsAString::const_
iterator start, nsAString::const_
iterator end, nsStringComparator& aComparator = nsDefaultStringComparator()); To use this, start and end should point to the beginning and end of a string that you would like to search. If the search string is found, start and end will be adjusted to point to the beginning and end of the found pattern. The return value is PR_TRUE or PR_FALSE, indica...
...And 6 more matches
Index - Archive of obsolete content
ume. ...
...ber the -time option, or you may be hitting that physical reset button sooner than you would have liked! ...
...nction, JavaScript, Obsolete, Property, Unimplemented Not part of any standard. 2012 Function.prototype.isGenerator() Function, JavaScript, Method, Non-standard, Obsolete The non-standard isGenerator() method used to determine whether or not a function is a generator. It has been removed from Firefox starting with version 58. 2013 Generator comprehensions
Iterator, JavaScript, Language feature, Non-standard, Obsolete, Reference The generator comprehension syntax was a JavaScript expression which allowed you to quickly assemble a new generator function based on an existing iterable object. However, it has been removed from the standard and the Firefox implementation. Do not use it! 2014 Legacy generator function JavaScript, Language fea...
...And 4 more matches
nsACString_internal
sACString_internal(const nsCSubstringTuple&) - source this is public to support automatic conversion of tuple to string base type, which helps avoid converting to nsTAString. ...
...nst nsCSubstringTuple&) - source this is public to support automatic conversion of tuple to string base type, which helps avoid converting to nsTAString. ...
...s is public to support automatic conversion of tuple to string base type, which helps avoid converting to nsTAString. ...
...And 4 more matches
nsAString_internal
ternal(const nsSubstringTuple&) - source this is public to support automatic conversion of tuple to string base type, which helps avoid converting to nsTAString. ...
...ingTuple&) - source this is public to support automatic conversion of tuple to string base type, which helps avoid converting to nsTAString. ...
...matic conversion of tuple to string base type, which helps avoid converting to nsTAString. ...
...And 4 more matches
Demo Addon
that button to show the demo overview. All three demos are explained in the following sections. Only the interesting parts are shown, it's recommended that you download the add-on and have a look at its files. The basics The interesting parts covered in this article are in the content folder. The toolbar button and its functionality are defined in overlay.xul and overlay.js. We make use of fix
Iterator(). It is a handy library that keeps your code cleaner and simpler. It lets you iterate over any collection and transforms your collection elements in the given objects, To use fix
Iterator, you have to import it with Cu.import("resource:///modules/
iteratorUtils.jsm");. Demo 1 - Iterate over all the accounts This demo is implemented in demo1.html in the content folder. It lists all your email acc...
...tion elements in the given objects, To use fix
Iterator, you have to import it with Cu.import("resource:///modules/
iteratorUtils.jsm");. Demo 1 - Iterate over all the accounts This demo is implemented in demo1.html in the content folder. It lists all your email accounts with their account type - either pop3 or imap - and the associated email addresses. ...
...Each account is a nsIMsgAccount. ...
...And 4 more matches
nsDependentSubstring
nsAString_internal Data Members No public members. ...
... members. ...
...onst nsAString_internal&, PRUint32, PRUint32) - source Parameters nsAString_internal& str PRUint32 startPos PRUint32 length void nsDependentSubstring(const PRUnichar*, const PRUnichar*) - source Parameters PRUnichar* start PRUnichar* end void nsDependentSubstring(const nsReading
Iterator<short unsigned int>&, const nsReading
Iterator<short unsigned int>&) - source Parameters nsReading
Iterator<short unsigned int>& start nsReading
Iterator<short unsigned int>& end void nsDependentSubstring() - source Rebind void Rebind(const nsAString_internal&, PRUint32, PRUint32) - source Parameters nsAString_internal& <anonymous> PRUint32 startPos PRUint32 length void Rebind(const PRUnichar*, const PRUnichar*) - source Parameters PRUnichar* start PRUnichar* end BeginReading P...
...And 3 more matches
NodeFilter.acceptNode() - Web APIs
The NodeFilter.acceptNode() method returns an unsigned short that will be used to tell if a given Node must be accepted or not by the Node
Iterator or TreeWalker iteration algorithm. This method is expected to be written by the user of a NodeFilter. Possible return values are: Constant Description NodeFilter.FILTER_ACCEPT Value returned by the NodeFilter.acceptNode() method when a node should be accepted. NodeFilter.FILTER_REJECT Value to be returned by the NodeFilter.acceptNode() method when a node should be rejected. The children of rejected nodes are not visited by the Node
Iterator or TreeWalker object; this value is treated as "skip this node and all its children". NodeFilter.FILTER_SKIP Value to be returned by NodeFilter.acceptNode() for nodes ...
...The children of skipped nodes are still considered. This is treated as "skip this node but not its children". ...
...ch causes the TreeWalker to return the node, NodeFilter.FILTER_REJECT, which causes the TreeWalker to ignore the entire subtree, or NodeFilter.FILTER_SKIP. The browser doesn't provide any object implementing this method. ...
...And 3 more matches
NodeFilter - Web APIs
A NodeFilter interface represents an object used to filter the nodes in a Node
Iterator or TreeWalker. A NodeFilter knows nothing about the document or traversing nodes; it only knows how to evaluate a single node against the provided filter. Note: The browser doesn't provide any object implementing this interface. It is the user who is expected to write one, tailoring the acceptNode() method to its needs, and using it with some TreeWalker or Node
Iterator objects. Properties This interface neither implements nor inherits any properties. Methods This interface doesn't inherit any methods. NodeFilter.acceptNode() Returns an unsigned short that will be used to tell if a given Node must be accepted or not by the Node
Iterator or TreeWalker iteration algorithm. This method is expected to ...
...the user of a NodeFilter. Possible return values are: Constant Description FILTER_ACCEPT Value returned by the NodeFilter.acceptNode() method when a node should be accepted. FILTER_REJECT Value to be returned by the NodeFilter.acceptNode() method when a node should be rejected. For TreeWalker, child nodes are also rejected. ...
...) method when a node should be accepted. FILTER_REJECT Value to be returned by the NodeFilter.acceptNode() method when a node should be rejected. For TreeWalker, child nodes are also rejected. For Node
Iterator, this flag is synonymous with FILTER_SKIP. FILTER_SKIP Value to be returned by NodeFilter.acceptNode() for nodes to be skipped by the Node
Iterator or TreeWalker object. The children of skipped nodes are still considered. This is treated as "skip this node but not its children". ...
...And 3 more matches
StopIteration - Archive of obsolete content
Examples StopIteration is thrown by
Iterator. ...
... Examples StopIteration is thrown by
Iterator. ...
... Examples StopIteration is thrown by
Iterator. ...
...And 2 more matches
nsDependentCSubstring
Base Classes nsACString_internal Data Members No public members. ...
...nal Data Members No public members. ...
... Constructors void nsDependentCSubstring(const nsACString_internal&, PRUint32, PRUint32) - source Parameters nsACString_internal& str PRUint32 startPos PRUint32 length void nsDependentCSubstring(const char*, const char*) - source Parameters char* start char* end void nsDependentCSubstring(const nsReading
Iterator<char>&, const nsReading
Iterator<char>&) - source Parameters nsReading
Iterator<char>& start nsReading
Iterator<char>& end void nsDependentCSubstring() - source Rebind void Rebind(const nsACString_internal&, PRUint32, PRUint32) - source Parameters nsACString_internal& <anonymous> PRUint32 startPos PRUint32 length void Rebind(const char*, const char*) - source Parameters char* start char* end BeginReading char* BeginReading() const - source reading ...
...And 2 more matches
ECMAScript 2015 support in Mozilla - Archive of obsolete content
ntAt() (Firefox 29) String.prototype.startsWith(), String.prototype.endsWith() (Firefox 17) String.prototype.includes() (Firefox 40) (formerly String.prototype.contains() (Firefox 17)) String.prototype.repeat() (Firefox 24) String.prototype.normalize() (Firefox 31) String.raw() (Firefox 34) \u{XXXXXX} Unicode code point escapes (Firefox 40) New Symbol object Symbol (Firefox 36) Symbol.
iterator (Firefox 36) Symbol.for() - global Symbol registry (Firefox 36) Symbol.match (Firefox 40) Symbol.species (Firefox 41) Symbol.toPrimitive (Firefox 44) Symbol.prototype[@@toPrimitive] (Firefox 44) Symbol.replace (Firefox 49) Symbol.search (Firefox 49) Symbol.split (Firefox 49) Symbol.hasInstance (Firefox 50) Typed Arrays Typed arrays are specified as part of ECMAScript 2015 and no longe...
... ECMAScript 2015 and no longer in their own specification. ...
...(Firefox 48) DataView Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array get %TypedArray%[@@species] (Firefox 48) Expressions and operators new.target (Firefox 41) Spread operator for arrays (Firefox 16) use Symbol.
iterator property (Firefox 36) Spread operator for function calls (Firefox 27) use Symbol.
iterator property (Firefox 36) const (JS 1.5, Firefox 1.0) (ES2015 compliance bug 950547 implemented in Firefox 51) let (JS 1.7, Firefox 2) (ES2015 compliance bug 950547 implemented in Firefox 51) Destructuring assignment (JS 1.7, Firefox 2) (ES2015 compliance bug 1055984) Statements for...of (Firefox 13) works in terms of .
iterator() and .next() (Firefox 17) use "@@
iterator" proper...
...onst (JS 1.5, Firefox 1.0) (ES2015 compliance bug 950547 implemented in Firefox 51) let (JS 1.7, Firefox 2) (ES2015 compliance bug 950547 implemented in Firefox 51) Destructuring assignment (JS 1.7, Firefox 2) (ES2015 compliance bug 1055984) Statements for...of (Firefox 13) works in terms of .
iterator() and .next() (Firefox 17) use "@@
iterator" property (Firefox 27) use Symbol.
iterator property (Firefox 36) Functions Rest parameters (Firefox 15) Default parameters (Firefox 15) Parameters without defaults after default parameters (Firefox 26) Destructured parameters with default value assignment (Firefox 41) Arrow functions (Firefox 22) Generator function (Firefox 26) yield (Firefox 26) yield* (Firefox 27) arguments[@@
iterator] (Firefox ...
WebIDL bindings
rs } Iterable Unlike maplike and setlike, iterable does not have any C++ helpers, as the structure backing the iterable data for the interface is left up to the developer. With that in mind, the generated iterable bindings expect the wrapper object to provide certain methods for the interface to access. Iterable interfaces have different requirements, based on if they are single or pair value
iterators. Example Interface for a single value
iterator: interface LongIterable { iterable<long>; getter long(unsigned long index); readonly attribute unsigned long length; }; For single value
iterator interfaces, we treat the interface as an indexed getter, as required by the spec. See the indexed getter implementation section for more information on building this kind of structure. Example In...
... a single value
iterator: interface LongIterable { iterable<long>; getter long(unsigned long index); readonly attribute unsigned long length; }; For single value
iterator interfaces, we treat the interface as an indexed getter, as required by the spec. See the indexed getter implementation section for more information on building this kind of structure. ...
...donly attribute unsigned long length; }; For single value
iterator interfaces, we treat the interface as an indexed getter, as required by the spec. See the indexed getter implementation section for more information on building this kind of structure. ...
...s=performSomething] void doSomething(); }; MyInterface.prototype.performSomething will have the same Function object value as MyInterface.prototype.doSomething. Multiple [Alias] extended attribute can be used on the one method. [Alias] cannot be used on a static method, nor on methods on a global interface (such as Window). Aside from regular property names, the name of an alias can be Symbol.
iterator. This is specified by writing [Alias="@@
iterator"]. [BindingAlias=propName] This extended attribute can be specified on an attribute and indicates that another property with the specified name will also appear on the interface prototype object and will call the same underlying C++ implementation for the getter and setter. This is more efficient than using the same BinaryName for both attributes...
XRInputSourceArray.entries() - Web APIs
Examples This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using. ...
...*/ } Parameters None. ...
... Examples This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using. ...
..., taken from its gamepad property, as an input For other devices, we look for tracked-pointer devices in the player's main hand, dispatching those to a handleMainHandInput() method. Specifications Specification Status Comment WebXR Device APIThe definition of 'XRInputSourceArray' in that specification.1 Working Draft XRInputSourceArray interface [1] See
Iterator-like methods in Information contained in a WebIDL file for information on how an iterable declaration in an interface definition causes entries(), forEach(), keys(), and values() methods to be exposed from objects that implement the interface. ...
XRInputSourceArray.keys() - Web APIs
Examples This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using. ...
... Examples This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using. ...
... Examples This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using. ...
...s[inputIdx]); } Here, for...of is used to iterate over each of the keys. For each key, the input is retrieved using the index with array notation: xrSession.inputSources[inputIdx]. Specifications Specification Status Comment WebXR Device APIThe definition of 'XRInputSourceArray' in that specification.1 Working Draft XRInputSourceArray interface [1] See
Iterator-like methods in Information contained in a WebIDL file for information on how an iterable declaration in an interface definition causes entries(), forEach(), keys(), and values() methods to be exposed from objects that implement the interface. ...
BigInt64Array - JavaScript
xed at construction time and thus read only. BigInt64Array.prototype.length Returns the number of elements hold in the BigInt64Array. This is fixed at construction time and thus read only. Instance methods BigInt64Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). BigInt64Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). BigInt64Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). BigInt64Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototyp...
...opriate. See also Array.prototype.includes(). BigInt64Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). BigInt64Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). BigInt64Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). BigInt64Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). BigInt64Array.prototype.map() Creates a new array with the results of calling a provided function on every elemen...
...least one element in this array satisfies the provided testing function. See also Array.prototype.some(). BigInt64Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). BigInt64Array.prototype.subarray() Returns a new BigUint64Array from the given start and end element index. BigInt64Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). BigInt64Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). BigInt64Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). BigInt64Array.pr...
...at contains the values for each index in the array. See also Array.prototype.values(). BigInt64Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). BigInt64Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). BigInt64Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a BigInt64Array // From a length var bigint64 = new BigInt64Array(2); bigint64[0] = 42n; console.log(bigint64[0]); // 42n console.log(bigint64.length); // 2 console.log(bigint64.BYTES_PER_ELEMENT); // 8 // From an array var arr = new BigInt64Array([21n,31n]); consol...
BigUint64Array - JavaScript
at construction time and thus read only. BigUint64Array.prototype.length Returns the number of elements hold in the BigUint64Array. This is fixed at construction time and thus read only. Instance methods BigUint64Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). BigUint64Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). BigUint64Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). BigUint64Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.protot...
...iate. See also Array.prototype.includes(). BigUint64Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). BigUint64Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). BigUint64Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). BigUint64Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). BigUint64Array.prototype.map() Creates a new array with the results of calling a provided function on every elem...
...st one element in this array satisfies the provided testing function. See also Array.prototype.some(). BigUint64Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). BigUint64Array.prototype.subarray() Returns a new BigUint64Array from the given start and end element index. BigUint64Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). BigUint64Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). BigUint64Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). BigUint64Array...
...contains the values for each index in the array. See also Array.prototype.values(). BigUint64Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). BigUint64Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). BigUint64Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a BigUint64Array // From a length var biguint64 = new BigUint64Array(2); biguint64[0] = 42n; console.log(biguint64[0]); // 42n console.log(biguint64.length); // 2 console.log(biguint64.BYTES_PER_ELEMENT); // 8 // From an array var arr = new BigUint64Array([21n,31n])...
Float32Array - JavaScript
ayBuffer. Fixed at construction time and thus read only. Float32Array.prototype.length Returns the number of elements hold in the Float32Array. Fixed at construction time and thus read only. Instance methods Float32Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Float32Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Float32Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Float32Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.
...ppropriate. See also Array.prototype.includes(). Float32Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Float32Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Float32Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Float32Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Float32Array.prototype.map() Creates a new array with the results of calling a provided function on every element ...
...f at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Float32Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Float32Array.prototype.subarray() Returns a new Float32Array from the given start and end element index. Float32Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Float32Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Float32Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Float32Array.proto...
... that contains the values for each index in the array. See also Array.prototype.values(). Float32Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Float32Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Float32Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a Float32Array // From a length var float32 = new Float32Array(2); float32[0] = 42; console.log(float32[0]); // 42 console.log(float32.length); // 2 console.log(float32.BYTES_PER_ELEMENT); // 4 // From an array var arr = new Float32Array([21,31]); console.log(arr[1]...
Float64Array - JavaScript
ayBuffer. Fixed at construction time and thus read only. Float64Array.prototype.length Returns the number of elements hold in the Float64Array. Fixed at construction time and thus read only. Instance methods Float64Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Float64Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Float64Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Float64Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.
...ppropriate. See also Array.prototype.includes(). Float64Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Float64Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Float64Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Float64Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Float64Array.prototype.map() Creates a new array with the results of calling a provided function on every element ...
...f at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Float64Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Float64Array.prototype.subarray() Returns a new Float64Array from the given start and end element index. Float64Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Float64Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Float64Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Float64Array.proto...
... that contains the values for each index in the array. See also Array.prototype.values(). Float64Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Float64Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Float64Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a Float64Array // From a length var float64 = new Float64Array(2); float64[0] = 42; console.log(float64[0]); // 42 console.log(float64.length); // 2 console.log(float64.BYTES_PER_ELEMENT); // 8 // From an array var arr = new Float64Array([21,31]); console.log(arr[1]...
Int16Array - JavaScript
its ArrayBuffer. Fixed at construction time and thus read only. Int16Array.prototype.length Returns the number of elements hold in the Int16Array. Fixed at construction time and thus read only. Instance methods Int16Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Int16Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Int16Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Int16Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fill...
...e as appropriate. See also Array.prototype.includes(). Int16Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Int16Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Int16Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Int16Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Int16Array.prototype.map() Creates a new array with the results of calling a provided function on every element in t...
...s true if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Int16Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Int16Array.prototype.subarray() Returns a new Int16Array from the given start and end element index. Int16Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Int16Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Int16Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Int16Array.prototype[@...
...object that contains the values for each index in the array. See also Array.prototype.values(). Int16Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Int16Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Int16Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create an Int16Array // From a length var int16 = new Int16Array(2); int16[0] = 42; console.log(int16[0]); // 42 console.log(int16.length); // 2 console.log(int16.BYTES_PER_ELEMENT); // 2 // From an array var arr = new Int16Array([21,31]); console.log(arr[1]); // 31 // Fr...
Int32Array - JavaScript
its ArrayBuffer. Fixed at construction time and thus read only. Int32Array.prototype.length Returns the number of elements hold in the Int32Array. Fixed at construction time and thus read only. Instance methods Int32Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Int32Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Int32Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Int32Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fill...
...e as appropriate. See also Array.prototype.includes(). Int32Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Int32Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Int32Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Int32Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Int32Array.prototype.map() Creates a new array with the results of calling a provided function on every element in t...
...s true if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Int32Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Int32Array.prototype.subarray() Returns a new Int32Array from the given start and end element index. Int32Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Int32Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Int32Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Int32Array.prototype[@...
...object that contains the values for each index in the array. See also Array.prototype.values(). Int32Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Int32Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Int32Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create an Int32Array // From a length var int32 = new Int32Array(2); int32[0] = 42; console.log(int32[0]); // 42 console.log(int32.length); // 2 console.log(int32.BYTES_PER_ELEMENT); // 4 // From an array var arr = new Int32Array([21,31]); console.log(arr[1]); // 31 // Fr...
Int8Array - JavaScript
t of its ArrayBuffer. Fixed at construction time and thus read only. Int8Array.prototype.length Returns the number of elements hold in the Int8Array. Fixed at construction time and thus read only. Instance methods Int8Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Int8Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Int8Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Int8Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fill()...
...alse as appropriate. See also Array.prototype.includes(). Int8Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Int8Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Int8Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Int8Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Int8Array.prototype.map() Creates a new array with the results of calling a provided function on every element in thi...
...turns true if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Int8Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Int8Array.prototype.subarray() Returns a new Int8Array from the given start and end element index. Int8Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Int8Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Int8Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Int8Array.prototype[@@it...
...s for each index in the array. See also Array.prototype.values(). Int8Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Int8Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Int8Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create an Int8Array // From a length var int8 = new Int8Array(2); int8[0] = 42; console.log(int8[0]); // 42 console.log(int8.length); // 2 console.log(int8.BYTES_PER_ELEMENT); // 1 // From an array var arr = new Int8Array([21,31]); console.log(arr[1]); // 31 // From another TypedArray var x = new Int8Arr...
String.prototype.matchAll() - JavaScript
The matchAll() method returns an
iterator of all results matching a string against a regular expression, including capturing groups. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax str.matchAll(regexp) Parameters regexp A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). The RegExp object must have the /g flag, otherwise a TypeError will be thrown. Return value An
iterator (which is not a restartable iterable). Examples Regexp.exec() and matchAll() Prior to the addition of matchAll to JavaScript, it was possible to...
...str = 'table football, foosball'; let match; while ((match = regexp.exec(str)) !== null) { console.log(`Found ${match[0]} start=${match.index} end=${regexp.lastIndex}.`); // expected output: "Found football start=6 end=14." // expected output: "Found foosball start=16 end=24." } With matchAll available, you can avoid the while loop and exec with g. ...
... const regexp = RegExp('[a-c]',''); const str = 'abc'; str.matchAll(regexp); // TypeError matchAll internally makes a clone of the regexp--so, unlike regexp.exec(), la...
... const regexp = RegExp('[a-c]',''); const str = 'abc'; str.matchAll(regexp); // TypeError matchAll internally makes a clone of the regexp--so, unlike regexp.exec(), lastIndex does not change as the string is scanned. const regexp = RegExp('[a-c]','g'); re...
TypedArray - JavaScript
its ArrayBuffer. Fixed at construction time and thus read only. TypedArray.prototype.length Returns the number of elements held in the typed array. Fixed at construction time and thus read only. Instance methods TypedArray.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). TypedArray.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). TypedArray.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). TypedArray.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fill...
...e as appropriate. See also Array.prototype.includes(). TypedArray.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). TypedArray.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). TypedArray.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). TypedArray.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). TypedArray.prototype.map() Creates a new array with the results of calling a provided function on every element in t...
...s true if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). TypedArray.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). TypedArray.prototype.subarray() Returns a new TypedArray from the given start and end element index. TypedArray.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). TypedArray.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). TypedArray.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). TypedArray.prototype[@...
...object that contains the values for each index in the array. See also Array.prototype.values(). TypedArray.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). TypedArray.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). TypedArray.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples New is required Starting with ECMAScript 2015, TypedArray constructors must be constructed with the new operator. Calling a TypedArray constructor as a function without new will throw a TypeError. var dv = Int8Array([1, 2, 3]); // TypeError: calling a builtin Int8Array constructor // withou...
Uint16Array - JavaScript
ArrayBuffer. Fixed at construction time and thus read only. Uint16Array.prototype.length Returns the number of elements hold in the Uint16Array. Fixed at construction time and thus read only. Instance methods Uint16Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Uint16Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Uint16Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Uint16Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fi...
...s appropriate. See also Array.prototype.includes(). Uint16Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Uint16Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Uint16Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Uint16Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Uint16Array.prototype.map() Creates a new array with the results of calling a provided function on every element in...
...ue if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Uint16Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Uint16Array.prototype.subarray() Returns a new Uint16Array from the given start and end element index. Uint16Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Uint16Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint16Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint16Array.prototyp...
...ect that contains the values for each index in the array. See also Array.prototype.values(). Uint16Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint16Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint16Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a Uint16Array // From a length var uint16 = new Uint16Array(2); uint16[0] = 42; console.log(uint16[0]); // 42 console.log(uint16.length); // 2 console.log(uint16.BYTES_PER_ELEMENT); // 2 // From an array var arr = new Uint16Array([21,31]); console.log(arr[1]); // 31...
Uint32Array - JavaScript
ArrayBuffer. Fixed at construction time and thus read only. Uint32Array.prototype.length Returns the number of elements hold in the Uint32Array. Fixed at construction time and thus read only. Instance methods Uint32Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Uint32Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Uint32Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Uint32Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fi...
...s appropriate. See also Array.prototype.includes(). Uint32Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Uint32Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Uint32Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Uint32Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Uint32Array.prototype.map() Creates a new array with the results of calling a provided function on every element in...
...ue if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Uint32Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Uint32Array.prototype.subarray() Returns a new Uint32Array from the given start and end element index. Uint32Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Uint32Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint32Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint32Array.prototyp...
...ect that contains the values for each index in the array. See also Array.prototype.values(). Uint32Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint32Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint32Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a Uint32Array // From a length var uint32 = new Uint32Array(2); uint32[0] = 42; console.log(uint32[0]); // 42 console.log(uint32.length); // 2 console.log(uint32.BYTES_PER_ELEMENT); // 4 // From an array var arr = new Uint32Array([21,31]); console.log(arr[1]); // 31...
Uint8Array - JavaScript
its ArrayBuffer. Fixed at construction time and thus read only. Uint8Array.prototype.length Returns the number of elements held in the Uint8Array. Fixed at construction time and thus read only. Instance methods Uint8Array.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Uint8Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Uint8Array.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Uint8Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.prototype.fill...
...e as appropriate. See also Array.prototype.includes(). Uint8Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Uint8Array.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Uint8Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Uint8Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Uint8Array.prototype.map() Creates a new array with the results of calling a provided function on every element in t...
...s true if at least one element in this array satisfies the provided testing function. See also Array.prototype.some(). Uint8Array.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Uint8Array.prototype.subarray() Returns a new Uint8Array from the given start and end element index. Uint8Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Uint8Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint8Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint8Array.prototype[@...
...object that contains the values for each index in the array. See also Array.prototype.values(). Uint8Array.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint8Array.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint8Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a Uint8Array // From a length var uint8 = new Uint8Array(2); uint8[0] = 42; console.log(uint8[0]); // 42 console.log(uint8.length); // 2 console.log(uint8.BYTES_PER_ELEMENT); // 1 // From an array var arr = new Uint8Array([21,31]); console.log(arr[1]); // 31 // Fro...
Uint8ClampedArray - JavaScript
onstruction time and thus read only. Uint8ClampedArray.prototype.length Returns the number of elements hold in the UintClamped8Array. Fixed at construction time and thus read only. Instance methods Uint8ClampedArray.prototype.copyWithin() Copies a sequence of array elements within the array. See also Array.prototype.copyWithin(). Uint8ClampedArray.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. See also Array.prototype.entries(). Uint8ClampedArray.prototype.every() Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every(). Uint8ClampedArray.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. See also Array.
... also Array.prototype.includes(). Uint8ClampedArray.prototype.indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.indexOf(). Uint8ClampedArray.prototype.join() Joins all elements of an array into a string. See also Array.prototype.join(). Uint8ClampedArray.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. See also Array.prototype.keys(). Uint8ClampedArray.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also Array.prototype.lastIndexOf(). Uint8ClampedArray.prototype.map() Creates a new array with the results of calling a provided function on ever...
...nt in this array satisfies the provided testing function. See also Array.prototype.some(). Uint8ClampedArray.prototype.sort() Sorts the elements of an array in place and returns the array. See also Array.prototype.sort(). Uint8ClampedArray.prototype.subarray() Returns a new Uint8ClampedArray from the given start and end element index. Uint8ClampedArray.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. See also Array.prototype.values(). Uint8ClampedArray.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint8ClampedArray.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint8Cla...
...the values for each index in the array. See also Array.prototype.values(). Uint8ClampedArray.prototype.toLocaleString() Returns a localized string representing the array and its elements. See also Array.prototype.toLocaleString(). Uint8ClampedArray.prototype.toString() Returns a string representing the array and its elements. See also Array.prototype.toString(). Uint8ClampedArray.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Different ways to create a Uint8ClampedArray // From a length var uintc8 = new Uint8ClampedArray(2); uintc8[0] = 42; uintc8[1] = 1337; console.log(uintc8[0]); // 42 console.log(uintc8[1]); // 255 (clamped) console.log(uintc8.length); // 2 console.log(uintc8.BYTES_PER_ELEMENT); // 1 // From ...
yield - JavaScript
unction (function* or legacy generator function). The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax [rv] = yield [expression] expression Optional Defines the value to return from the generator function via the
iterator protocol. If omitted, undefined is returned instead. rv Optional Retrieves the optional value passed to the generator's next() method to resume its execution. Description The yield keyword pauses generator function execution and the value of the expression following the yield keyword is returned to the generator's caller. It can be thought of as a generator-based version of the return ke...
...tion and the value of the expression following the yield keyword is returned to the generator's caller. It can be thought of as a generator-based version of the return keyword. yield can only be called directly from the generator function that contains it. It cannot be called from nested functions or from callbacks. The yield keyword causes the call to the generator's next() method to return an
IteratorResult object with two properties: value and done. The value property is the result of evaluating the yield expression, and done is false, indicating that the generator function has not fully completed. Once paused on a yield expression, the generator's code execution remains paused until the generator's next() method is called. Each time the generator's next() method is called, the generator res...
...alue. The next time next() is called, execution resumes with the statement immediately after the yield. throw is used to throw an exception from the generator. This halts execution of the generator entirely, and execution resumes in the caller (as is normally the case when an exception is thrown). The end of the generator function is reached. In this case, execution of the generator ends and an
IteratorResult is returned to the caller in which the value is undefined and done is true. A return statement is reached. In this case, execution of the generator ends and an
IteratorResult is returned to the caller in which the value is the value specified by the return statement and done is true. If an optional value is passed to the generator's next() method, that value becomes the value returned by...
... sends a value to the currently suspended yield, but returns the operand of the following yield. Examples Using yield The following code is the declaration of an example generator function. function* countAppleSales () { let saleList = [3, 7, 5] for (let i = 0; i < saleList.length; i++) { yield saleList[i] } } Once a generator function is defined, it can be used by constructing an
iterator as shown. let appleStore = countAppleSales() // Generator { } console.log(appleStore.next()) // { value: 3, done: false } console.log(appleStore.next()) // { value: 7, done: false } console.log(appleStore.next()) // { value: 5, done: false } console.log(appleStore.next()) // { value: undefined, done: true } You can also send a value with next(value) into the generator. 'ste...
for...of - JavaScript
function* foo(){ yield 1; yield 2; yield 3; }; for (const o of foo()) { console.log(o);...
...g over DOM collections like NodeList: the following example adds a read class to paragraphs that are direct descendants of an article: // Note: This will only work in platforms that have // implemented NodeList.prototype[Symbol.
iterator] const articleParagraphs = document.querySelectorAll('article > p'); for (const paragraph of articleParagraphs) { paragraph.classList.add('read'); } Closing
iterators In for...of loops, abrupt iteration termination can be caused by break, throw or return. In these cases, the
iterator is closed. function* foo(){ yield 1; yield 2; yield 3; }; for (const o of foo()) { console.log(o); break; // closes
iterator, execution continues outside of the loop } console.log('done'); Iterating over generators You can also iterate over generators, i.e. functi...
...reak; } } Do not reuse generators Generators should not be re-used, even if the for...of loop is terminated early, for example via the break keyword. Upon exiting a loop, the generator is closed and trying to iterate over it again does not yield any further results. ...
...eld 1; yield 2; yield 3; })(); for (const o of gen) { console.log(o); break; // Closes
iterator } // The generator should not be re-used, the following does not make sense! for (const o of gen) { console.log(o); // Never called. } Iterating over other iterable objects You can also iterate over an object that explicitly implements the iterable protocol: const iterable = { [Symbol.
iterator]() { return { i: 0, next() { if (this.i < 3) { return { value: this.i++, done: false }; } return { value: undefined, done: true }; } }; } }; for (const value of iterable) { console.log(value); } // 0 // 1 // 2 Difference between for...of and for...in Both for...in and for...of statements iterate over something. The main differenc...
util/array - Archive of obsolete content
e new, duplicate-free array. flatten(array) Flattens a nested array of any depth. let { flatten } = require('sdk/util/array'); let a = ['cut', ['ice', ['fire']], 'elec']; let b = flatten(a); console.log(a); // ['cut', ['ice', ['fire']], 'elec'] console.log(b); // ['cut', 'ice', 'fire', 'elec']; Parameters array : array The array to flatten. Returns array : The new, flattened array. from
Iterator(
iterator) Iterates over an
iterator and returns the results as an array. let { from
Iterator } = require('sdk/util/array'); let i = new Set(); i.add('otoro'); i.add('unagi'); i.add('keon'); from
Iterator(i) // ['otoro', 'unagi', 'keon'] Parameters
iterator :
iterator The
Iterator object over which to iterate and place results into an array. Returns array : The
iterator's results in an arra...
...If such element is found it's retured back otherwise third optional fallback argument is returned back. If fallback is not provided returns undefined. ...
... until predicate(element) is true. If such element is found it's retured back otherwise third optional fallback argument is returned back. If fallback is not provided returns undefined. let { find } = require('sdk/util/array'); let isOdd = (x) => x % 2; find([2, 4, 5, 7, 8, 9], isOdd); // => 5 find([2, 4, 6, 8], isOdd); // => undefiend find([2, 4, 6, 8], isOdd, null); // => null from
Iterator(i) // ['otoro', 'unagi', 'keon'] Parameters
iterator :
iterator The
Iterator object over which to iterate and place results into an array. Returns array : The
iterator's results in an array. ...
Generator comprehensions - Archive of obsolete content
Generators enable lazy computation of sequences, with items calculated on-demand as they are needed. Generator comprehensions are syntactically almost identical to array comprehensions -- they use parentheses instead of braces-- but instead of building an array they create a generator that can execute lazily. You can think of them as short hand syntax for creating generators. ...
...hey are needed. Generator comprehensions are syntactically almost identical to array comprehensions -- they use parentheses instead of braces-- but instead of building an array they create a generator that can execute lazily. You can think of them as short hand syntax for creating generators. Suppose we have an
iterator it which iterates over a large sequence of integers. We want to create a new
iterator that will iterate over their doubles. ...
...of them as short hand syntax for creating generators. Suppose we have an
iterator it which iterates over a large sequence of integers. We want to create a new
iterator that will iterate over their doubles. ...
Looping code - Learn web development
A counter, which is initialized with a certain value -- this is the starting point of the loop ("Start: I have no food", above). A condition, which is a true/false test to determine whether the loop continues to run, or stops -- usually when the counter reaches a certain value. This is illustrated by "Have I got enough food?", above. Let's say he needs 10 portions of food to feed his family. An
iterator, which generally increments the counter by a small amount on each successive loop, until the condition is no longer true. We haven't explicitly illustrated this above, but we could think about the farmer being able to collect say 2 portions of food per hour. After each hour, the amount of food he has collected is incremented by two, and he checks whether he has enough food. If he has reached 10 p...
....floor(sqRoot) !== sqRoot) { continue; } para.textContent += i + ' '; } }); </script> </body> </html> In this case, the input should be a number (num). The for loop is given a counter starting at 1 (as we are not interested in 0 in this case), an exit condition that says the loop will stop when the counter becomes bigger than the input num, and an
iterator that adds 1 to the counter each time. Inside the loop, we find the square root of each number using Math.sqrt(i), then check whether the square root is an integer by testing whether it is the same as itself when it has been rounded down to the nearest integer (this is what Math.floor() does to the number it is passed). If the square root and the rounded down square root do not equal one another...
... Different iteration numbers require different text to be put in the paragraph for that iteration (you'll need a conditional statement and multiple para.textContent = lines): If the number is 10, print "Countdown 10" to the paragraph. If the number is 0, print "Blast off!" to the paragraph. For any other number, print just the number to the paragraph. Remember to include an
iterator! However, in this example we are counting down after each iteration, not up, so you don't want i++ -- how do you iterate downwards? Note: If you start typing the loop (for example (while(i>=0)), the browser might stuck because you have not yet entered the end condition. So be careful with this. You can start writing your code in a comment to deal with this issue and remove the comment after yo...
OSFile.jsm
er system-specific information that the developer can use to optimize his algorithms for a platform. Using OS.File ... from the main thread Most uses of OS.File are from the main thread. In this mode, main thread clients use the API to request off main thread file I/O. Calling OS.File from the main thread Asynchronous, off-main thread file I/O, main thread API. Calling OS.File.Directory
Iterator from the main thread Asynchronous, off-main thread file directory access, main thread API. ... from a worker thread In some cases, the main thread API for OS.File is not appropriate as it would require too much message passing, or because the code that requires file I/O is already executed on a worker thread. For this reason, API clients can also spawn their own worker threads and make use of...
... In some cases, the main thread API for OS.File is not appropriate as it would require too much message passing, or because the code that requires file I/O is already executed on a worker thread. For this reason, API clients can also spawn their own worker threads and make use of OS.File directly from these threads. ...
... threads. OS.File for workers Synchronous file I/O for worker threads OS.File.Directory
Iterator for workers Visiting directories synchronously from a worker thread ... ...
Index
API return value, such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI entry points expecting a jsid and do not need to handle JSID_VOID in hooks receiving a jsid except when explicitly noted in the API contract. 122 JSIdArray JSAPI Reference, SpiderMonkey JSIdArray is used to hold IDs for enumerated properties associated with an object. 123 JS
IteratorOp JSAPI Reference, Obsolete, Reference, Reference(2), SpiderMonkey The JavaScript engine calls the JSExtendedClass.
iteratorObject callback to create an
iterator object for a given object. The callback should return an
iterator object or NULL if an error or exception occurred on cx. 124 JSMarkOp JSAPI Reference, Obsolete, Reference, Reference(2), SpiderMonkey Call JS...
... parent, then invokes a constructor function to initialize the new object. cx is a pointer to a context associated with the runtime in which to create the new object. clasp is a pointer to the class of object to create. proto and parent may specify objects to be used as the new object's prototype and parent. If either is NULL, the engine tries to find reasonable defaults. 218 JS_Context
Iterator JSAPI Reference, SpiderMonkey JS_Context
Iterator steps through the set of contexts associated with the runtime rt. Each call to JS_Context
Iterator returns the next context in the cycle. 219 JS_ConvertArguments JSAPI Reference, Obsolete, SpiderMonkey JS_ConvertArguments provides a convenient way to translate a series of JS values into their corresponding JS types wit...
...s a new object exactly as the given constructor would if invoked with new. This function does not run the code of the constructor function--it just creates the object. 409 JS_NewPlainObject JSAPI Reference, Reference, Reference(2), SpiderMonkey JS_NewPlainObject creates a new plain object, like new Object(), with Object.prototype as [[Prototype]]. 410 JS_NewProperty
Iterator JSAPI Reference, Obsolete, SpiderMonkey Create an object to iterate over the enumerable own properties of obj, in arbitrary order. (This differs from longstanding for..in loop order, which uses the order in which obj's properties were defined. Note also that while for..in includes properties inherited from prototypes,
iterator objects do not.) 411 JS_NewRegExpObject JSAPI...
JSAPI reference
irefox 5. Firefox 4 is the last release that has a corresponding SpiderMonkey release with the old scheme, where the JSAPI has the version 1.8.5. ...
... JS_GetMethod Obsolete since JSAPI 23 JS_GetMethodById Obsolete since JSAPI 23 A SpiderMonkey extension allow...
...when creating a custom JSClass: JS_PropertyStub JS_StrictPropertyStub Added in SpiderMonkey 1.9.3 JS_ConvertStub Obsolete since JSAPI 37 JS_DeletePropertyStub Obsolete since JSAPI 37 JS_EnumerateStub Obsolete since JSAPI 37 JS_FinalizeStub Obsolete since JSAPI 15 JS_ResolveStub Obsolete since JSAPI 37 JSExtendedClass method types: In JS 1.8.5, JSExtendedClass has made private. JS
IteratorOp Obsolete since JSAPI 26 JSEqualityOp Obsolete since JavaScript 1.8.5 JSObjectOp Obsolete since JavaScript 1.8.5 JSObjectOps method types: In JS 1.8.5, JSObjectOps has been made private. JSNewObjectMapOp Obsolete since JavaScript 1.8.5 JSObjectMapOp Obsolete since JavaScript 1.8.5 JSLookupPropOp Obsolete since JavaScript 1.8.5 JSDefinePropOp Obsolete since JavaScript 1.8.5 JSProperty...
Avoiding leaks in JavaScript XPCOM components
s not needed. Consider this example from bug 285065: function _filterRadioGroup(aNode) { switch (aNode.localName) { case "radio": return NodeFilter.FILTER_ACCEPT; case "template": case "radiogroup": return NodeFilter.FILTER_REJECT; default: return NodeFilter.FILTER_SKIP; } } var
iterator = this.ownerDocument.createTreeWalker(this, NodeFilter.SHOW_ELEMENT, _filterRadioGroup, true); while (
iterator.nextNode()) radioChildren.push(
iterator.currentNode); return this.mRadioChildren = radioChildren; In this example, the
iterator object is an XPCOM object that is wrapped so the JavaScript code can use it. The _filterRadioGroup object is a JavaScript ...
... radioChildren.push(
iterator.currentNode); return this.mRadioChildren = radioChildren; In this example, the
iterator object is an XPCOM object that is wrapped so the JavaScript code can use it. The _filterRadioGroup object is a JavaScript function that is wrapped so that XPCOM code can use it. The reason closures matter here is that the _filterRadioGroup function has access to the
iterator variable. (var declarations inside JavaScript functions are function-scope, including the part of the function before the declaration.) This means that the value of
iterator, the wrapper for the native tree walker, is reachable from the function. But the tree walker owns a reference to the wrapper for that function, so the wrapper maintains a garbage collection root to keep the function from bein...
...However, a better fix is to move the filter function outside of the function, since the power of closures is not necessary in this case (and there's also no need to create a new function object for the filter each time this code is executed). ...
Index
stance, use: 465 nsIDNSListener Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference Called when an asynchronous host lookup completes. 466 nsIDNSRecord Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference This function copies the value of the next IP address into the given PRNetAddr struct and increments the internal address
iterator. 467 nsIDNSRequest Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference Called to cancel a pending asynchronous DNS request. The listener will passed to asyncResolve will be notified immediately with a status code of NS_ERROR_ABORT. 468 nsIDNSService Interfaces, Interfaces:Scriptable, XPCOM, XPCOM API Reference, XPCOM Interface Reference Im...
...e, XPCOM, XPCOM Interface Reference, XPath No summary! 529 nsIDOMXPathExpression DOM, Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference, XPath Evaluate the XPath expression. 530 nsIDOMXPathResult DOM, Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference, XPath Iterates through the available nodes of an UNORDERED_NODE_
ITERATOR_TYPE or ORDERED_NODE_
ITERATOR_TYPE result. 531 nsIDOMXULControlElement Interfaces, Interfaces:Scriptable, Reference, Reference(2), XPCOM Interface Reference No summary! 532 nsIDOMXULElement Interfaces, Interfaces:Scriptable, NeedsContent, XPCOM, XPCOM Interface Reference Attempts to remove focus from the element. 533 nsIDOMXULLabeledControlElem...
...ble, XPCOM, XPCOM API Reference, XPCOM Interface Reference Called for each directory entry. 548 nsIDirectoryEnumerator Directories, File I/O, Interfaces, Interfaces:Scriptable, XPCOM, XPCOM API Reference, XPCOM Interface Reference Closes the directory being enumerated, releasing the system resource. It is safe to call this function many times. 549 nsIDirectory
Iterator Directories, File I/O, Interfaces, Interfaces:Scriptable, NeedsContent, XPCOM Interface Reference The nsIDirectory
Iterator interface provides a way to iterate over the entries in a directory. 550 nsIDirectoryService Interfaces, Interfaces:Scriptable, XPCOM, XPCOM API Reference, XPCOM Interface Reference Initializes the nsIDirectoryService instance. 551 in...
NS_ConvertASCIItoUTF16
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
NS_ConvertUTF8toUTF16
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsAdoptingString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsAutoString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsCAutoString
32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters ...
...
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter ...
...e Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting(char*&) - source Parameters char*& iter Data char* Data() const - source accessors Length PRUint32 Length() const - source IsEmpty PRBool IsEmpty() const - source IsVoid PRBool IsVoid() const - source IsTerminated ...
nsDependentString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsFixedString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsPromiseFlatString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsXPIDLString
his string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading PRUnichar* BeginReading() const - source reading
iterators nsReading
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading...
...ing
Iterator<short unsigned int>& BeginReading(nsReading
Iterator<short unsigned int>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& BeginReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter EndReading PRUnichar* EndReading() const - source nsReading
Iterator<short unsigned int>& EndReading(nsReading
Iterator<short unsigned int>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Para...
...nt>&) const - source Parameters nsReading
Iterator<short unsigned int>& iter PRUnichar*& EndReading(const PRUnichar*&) const - source Parameters PRUnichar*& iter BeginWriting PRUnichar* BeginWriting() - source writing
iterators nsWriting
Iterator<short unsigned int>& BeginWriting(nsWriting
Iterator<short unsigned int>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& BeginWriting(PRUnichar*&) - source Parameters PRUnichar*& iter EndWriting PRUnichar* EndWriting() - source nsWriting
Iterator<short unsigned int>& EndWriting(nsWriting
Iterator<short unsigned int>&) - source Parameters nsWriting
Iterator<short unsigned int>& iter PRUnichar*& EndWriting(PRUnichar*&) - source Parameters PRUnichar*& iter ...
nsIDOMXPathResult
esult returned by nsIDOMXPathEvaluator or document.evaluate Inherits from: nsISupports Last changed in Gecko 1.7 Method overview nsIDOMNode iterateNext(); nsIDOMNode snapshotItem(in unsigned long index); Attributes Attribute Type Description booleanValue boolean If resultType is BOOLEAN_TYPE, the boolean value. Read only. invalid
IteratorState boolean true if the
iterator state has become invalid. For example, modifying a node invalidates the
iterator. Read only. numberValue double If resultType is NUMBER_TYPE, the numeric value of the XPath value. Read only. resultType unsigned short The type of result; can be any of the Type constants except ANY_TYPE. Read only. singleNodeValue nsI...
... Read only. Constants Type constants Constant Value Description ANY_TYPE 0 Used when evaluating an XPath expression; the evaluator will return the most appropriate type. NUMBER_TYPE 1 Type is a single number. STRING_TYPE 2 Type is a single string. BOOLEAN_TYPE 3 Type is a single boolean value. UNORDERED_NODE_
ITERATOR_TYPE 4 Type is a reference to all the nodes matching the expression used in the evaluator. The nodes may not necessarily be in the same order that they appear in the document. ORDERED_NODE_
ITERATOR_TYPE 5 Type is a reference to all the nodes matching the expression used in the evaluator. The nodes in the result set are in the same order that they appear in the document. ...
...RED_NODE_TYPE 8 Type is a single node that matches the expression. The node is not necessarily the first node in the document that matches the expression used in the evaluator. FIRST_ORDERED_NODE_TYPE 9 Type is the first node in the document that matches the expression used in the evaluator. Methods iterateNext() Iterates through the available nodes of an UNORDERED_NODE_
ITERATOR_TYPE or ORDERED_NODE_
ITERATOR_TYPE result. nsIDOMNode iterateNext(); Parameters None. Return value A DOM node. snapshotItem() Returns the specified node from what is essentially an array of resulting DOM nodes. Is only available if the result type is UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE. nsIDOMNode snapshotItem( in unsigned long index ); Parameters index The ind...
Document.evaluate() - Web APIs
.ANY_TYPE, of the XPathResult constructor, which correspond to integers from 0 to 9. result is an existing XPathResult to use for the results. null is the most common and will create a new XPathResult Example var headings = document.evaluate("/html/body//h2", document, null, XPathResult.ANY_TYPE, null); /* Search the document for all h2 elements. * The result will likely be an unordered node
iterator. */ var thisHeading = headings.iterateNext(); var alertText = "Level 2 headings in this document are:\n"; while (thisHeading) { alertText += thisHeading.textContent + "\n"; thisHeading = headings.iterateNext(); } alert(alertText); // Alerts the text of all h2 elements Note, in the above example, a more verbose XPath is preferred over common shortcuts such as //h2. Generally, more specific X...
...ven expression. NUMBER_TYPE 1 A result set containing a single number. Useful, for example, in an XPath expression using the count() function. STRING_TYPE 2 A result set containing a single string. BOOLEAN_TYPE 3 A result set containing a single boolean value. Useful, for example, an an XPath expression using the not() function. UNORDERED_NODE_
ITERATOR_TYPE 4 A result set containing all the nodes matching the expression. The nodes in the result set are not necessarily in the same order they appear in the document. ORDERED_NODE_
ITERATOR_TYPE 5 A result set containing all the nodes matching the expression. The nodes in the result set are in the same order they appear in the document. UNORDERED_NODE_SNAPSHOT_TYPE 6...
...et are in the same order they appear in the document. ANY_UNORDERED_NODE_TYPE 8 A result set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression. FIRST_ORDERED_NODE_TYPE 9 A result set containing the first node in the document that matches the expression. Results of NODE_
ITERATOR types contain references to nodes in the document. Modifying a node will invalidate the
iterator. After modifying a node, attempting to iterate through the results will result in an error. Results of NODE_SNAPSHOT types are snapshots, which are essentially lists of matched nodes. You can make changes to the document by altering snapshot nodes. Modifying the document doesn't invalidate the snapsh...
NodeList - Web APIs
cache the list's length. Properties NodeList.length The number of nodes in the NodeList. Methods NodeList.item() Returns an item in the list by its index, or null if the index is out-of-bounds. An alternative to accessing nodeList[i] (which instead returns undefined when i is out-of-bounds). This is mostly useful for non-JavaScript DOM implementations. ...
...ful for non-JavaScript DOM implementations. NodeList.entries() Returns an
iterator, allowing code to go through all key/value pairs contained in the collection. (In this case, the keys are numbers starting from 0 and the values are nodes.) NodeList.forEach() Executes a provided function once per NodeList element, passing the element as an argument to the function. NodeList.keys() Returns an
iterator, allowing code to go through all the keys of the key/value pairs contained in the collection. (In this case, the keys are numbers starting from 0.) NodeList.values() Returns an
iterator allowing code to go through all values (nodes) of the key/value pairs contained in the collection. Example It's possible to loop over the items in a NodeList using a for loop: for (let i = 0; i < myNodeList.
...ngth and item properties and cause errors if your script assumes it only has to deal with element objects. Also, for..in is not guaranteed to visit the properties in any particular order. for...of loops will loop over NodeList objects correctly: const list = document.querySelectorAll('input[type=checkbox]'); for (let checkbox of list) { checkbox.checked = true; } Recent browsers also support
iterator methods (forEach()) as well as entries(), values(), and keys(). There is also an Internet Explorer-compatible way to use Array.prototype.forEach for iteration: const list = document.querySelectorAll('input[type=checkbox]'); Array.prototype.forEach.call(list, function (checkbox) { checkbox.checked = true; }); Specifications Specification Status Comment DOMThe defi...
URLSearchParams - Web APIs
{} Note: This feature is available in Web Workers. Constructor URLSearchParams() Returns a URLSearchParams object instance. Methods URLSearchParams.append() Appends a specified key/value pair as a new search parameter. URLSearchParams.delete() Deletes the given search parameter, and its associated value, from the list of all search parameters. URLSearchParams.entries() Returns an
iterator allowing iteration through all key/value pairs contained in this object. URLSearchParams.forEach() Allows iteration through all values contained in this object via a callback function. URLSearchParams.get() Returns the first value associated with the given search parameter. URLSearchParams.getAll() Returns all the values associated with a given search parameter. URLSearchParams.has() Retu...
...ach() Allows iteration through all values contained in this object via a callback function. URLSearchParams.get() Returns the first value associated with the given search parameter. URLSearchParams.getAll() Returns all the values associated with a given search parameter. URLSearchParams.has() Returns a Boolean indicating if such a given parameter exists. URLSearchParams.keys() Returns an
iterator allowing iteration through all keys of the key/value pairs contained in this object. URLSearchParams.set() Sets the value associated with a given search parameter to the given value. If there are several values, the others are deleted. URLSearchParams.sort() Sorts all key/value pairs, if any, by their keys. URLSearchParams.toString() Returns a string containing a query string suitable for u...
...ue pairs contained in this object. URLSearchParams.set() Sets the value associated with a given search parameter to the given value. If there are several values, the others are deleted. URLSearchParams.sort() Sorts all key/value pairs, if any, by their keys. URLSearchParams.toString() Returns a string containing a query string suitable for use in a URL. URLSearchParams.values() Returns an
iterator allowing iteration through all values of the key/value pairs contained in this object. Examples var paramsString = "q=URLUtils.searchParams&topic=api"; var searchParams = new URLSearchParams(paramsString); //Iterate the search parameters. for (let p of searchParams) { console.log(p); } searchParams.has("topic") === true; // true searchParams.get("topic") === "api"; // true searchParams.get...
XPathResult.resultType - Web APIs
yntax var resultType = result.resultType; Return value An integer value representing the type of the result, as defined by the type constants. Constants Result Type Defined Constant Value Description ANY_TYPE 0 A result set containing whatever type naturally results from evaluation of the expression. Note that if the result is a node-set then UNORDERED_NODE_
ITERATOR_TYPE is always the resulting type. NUMBER_TYPE 1 A result containing a single number. This is useful for example, in an XPath expression using the count() function. STRING_TYPE 2 A result containing a single string. BOOLEAN_TYPE 3 A result containing a single boolean value. This is useful for example, in an XPath expression using the not() function. ...
...sulting type. NUMBER_TYPE 1 A result containing a single number. This is useful for example, in an XPath expression using the count() function. STRING_TYPE 2 A result containing a single string. BOOLEAN_TYPE 3 A result containing a single boolean value. This is useful for example, in an XPath expression using the not() function. UNORDERED_NODE_
ITERATOR_TYPE 4 A result node-set containing all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document. ORDERED_NODE_
ITERATOR_TYPE 5 A result node-set containing all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document. UNORDERED_NODE_SNAPSHOT_TYPE...
...the expression. Example The following example shows the use of the resultType property. HTML <div>XPath example</div> <div>Is XPath result a node set: <output></output></div> JavaScript var xpath = "//div"; var result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null); document.querySelector("output").textContent = result.resultType >= XPathResult.UNORDERED_NODE_
ITERATOR_TYPE && result.resultType <= XPathResult.FIRST_ORDERED_NODE_TYPE; Result Specifications Specification Status Comment Document Object Model (DOM) Level 3 XPath SpecificationThe definition of 'XPathResult.resultType' in that specification. Recommendation Initial definition ...
XPathResult - Web APIs
ts the results generated by evaluating an XPath expression within the context of a given node. Since XPath expressions can result in a variety of result types, this interface makes it possible to determine and handle the type and value of the result. Properties XPathResult.booleanValueRead only A boolean representing the value of the result if resultType is BOOLEAN_TYPE. XPathResult.invalid
IteratorStateRead only Signifies that the
iterator has become invalid. It is true if resultType is UNORDERED_NODE_
ITERATOR_TYPE or ORDERED_NODE_
ITERATOR_TYPE and the document has been modified since this result was returned. XPathResult.numberValueRead only A number representing the value of the result if resultType is NUMBER_TYPE. XPathResult.resultTypeRead only A number code representing the typ...
...eRead only A string representing the value of the result if resultType is STRING_TYPE. Methods XPathResult.iterateNext() If the result is a node set, this method iterates over it and returns the next node from it or null if there are no more nodes. XPathResult.snapshotItem() Returns an item of the snapshot collection or null in case the index is not within the range of nodes. Unlike the
iterator result, the snapshot does not become invalid, but may not correspond to the current document if it is mutated. Constants Result Type Defined Constant Value Description ANY_TYPE 0 A result set containing whatever type naturally results from evaluation of the expression. Note that if the result is a node-set then UNORDERED_NODE_
ITERATOR_TYPE is always the result...
...sulting type. NUMBER_TYPE 1 A result containing a single number. This is useful for example, in an XPath expression using the count() function. STRING_TYPE 2 A result containing a single string. BOOLEAN_TYPE 3 A result containing a single boolean value. This is useful for example, in an XPath expression using the not() function. UNORDERED_NODE_
ITERATOR_TYPE 4 A result node-set containing all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document. ORDERED_NODE_
ITERATOR_TYPE 5 A result node-set containing all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document. UNORDERED_NODE_SNAPSHOT_TYPE...
XRInputSourceArray - Web APIs
esents a live list of WebXR input sources, and is used as the return value of the XRSession property inputSources. Each entry is an XRInputSource representing one input device connected to the WebXR system. ...
...hods are available to allow the use of
iterators and the forEach() method is also available. Properties The following properties are available on XRInputSourceArray objects. length Read only The number of XRInputSource objects in the list. Methods The following methods are available on XRInputSourceArray objects. You may also use the features of the Symbol type. entries() Returns an
iterator you can use to walk the list of key/value pairs in the list. Each item returned is an array whose first value is the index and whose second value is the XRInputSource at that index. forEach() Iterates over each item in the list, in order from first to last. keys() A list of the keys corresponding to the entries in the input source list. ...
...Each item is a single XRInputSource object. In addition to these methods, you may use array notation to access items in the list by index For example, the snippet of code below calls a function handleInput(), passing into it the first item in the input source list, if the list isn't empty. ...
TypeError: 'x' is not iterable - JavaScript
object corresponding to the generator is callable, but not iterable. Calling a generator produces an iterable object which will iterate over the values yielded during the execution of the generator. function* generate(a, b) { yield a; yield b; } for (let x of generate(1,2)) console.log(x); Iterating over a custom iterable Custom iterables can be created by implementing the Symbol.
iterator method. You must be certain that your
iterator method returns an object which is an
iterator, which is to say it must have a next method. const myEmptyIterable = { [Symbol.
iterator]() { return [] // [] is iterable, but it is not an
iterator -- it has no next method. } } Array.from(myEmptyIterable); // TypeError: myEmptyIterable is not iterable Here is a correct implementation...
...erator method returns an object which is an
iterator, which is to say it must have a next method. const myEmptyIterable = { [Symbol.
iterator]() { return [] // [] is iterable, but it is not an
iterator -- it has no next method. ...
...s an
iterator, which is to say it must have a next method. const myEmptyIterable = { [Symbol.
iterator]() { return [] // [] is iterable, but it is not an
iterator -- it has no next method. ...
Array.prototype.entries() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax array.entries() Return value A new Array
iterator object. ...
... The entries() method returns a new Array
Iterator object that contains the key/value pairs for each index in the array. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
...amples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax array.entries() Return value A new Array
iterator object. Examples Iterating with index and element const a = ['a', 'b', 'c']; for (const [index, element] of a.entries()) console.log(index, element); // 0 'a' // 1 'b' // 2 'c' Using a for...of loop var a = ['a', 'b', 'c']; var
iterator = a.entries(); for (let e of
iterator) { console.log(e); } // [0, 'a'] // [1, 'b'] // [2, 'c'] Specifications Specification ECMAScript (ECMA-262)The definition of 'Array.prototype.entries' in that specification. ...
Array - JavaScript
mber of elements in an array. Array.prototype[@@unscopables] A symbol containing property names to exclude from a with binding scope. Instance methods Array.prototype.concat() Returns a new array that is this array joined with other array(s) and/or value(s). Array.prototype.copyWithin() Copies a sequence of array elements within the array. Array.prototype.entries() Returns a new Array
Iterator object that contains the key/value pairs for each index in the array. Array.prototype.every() Returns true if every element in this array satisfies the testing function. Array.prototype.fill() Fills all the elements of an array from a start index to an end index with a static value. Array.prototype.filter() Returns a new array containing all elements of the calling array for which the provi...
... for each element in the array. Array.prototype.includes() Determines whether the array contains a value, returning true or false as appropriate. Array.prototype.indexOf() Returns the first (least) index of an element within the array equal to an element, or -1 if none is found. Array.prototype.join() Joins all elements of an array into a string. Array.prototype.keys() Returns a new Array
Iterator that contains the keys for each index in the array. Array.prototype.lastIndexOf() Returns the last (greatest) index of an element within the array equal to an element, or -1 if none is found. Array.prototype.map() Returns a new array containing the results of calling a function on every element in this array. Array.prototype.pop() Removes the last element from an array and returns that elem...
...presenting the array and its elements. Overrides the Object.prototype.toLocaleString() method. Array.prototype.toString() Returns a string representing the array and its elements. Overrides the Object.prototype.toString() method. Array.prototype.unshift() Adds one or more elements to the front of an array, and returns the new length of the array. Array.prototype.values() Returns a new Array
Iterator object that contains the values for each index in the array. Array.prototype[@@
iterator]() Returns a new Array
Iterator object that contains the values for each index in the array. Examples Creating an array The following example creates an array, msgArray, with a length of 0, then assigns values to msgArray[0] and msgArray[99], changing the length of the array to 100. let msgArray = [] ms...
Map - JavaScript
(key) will return false afterwards. Map.prototype.get(key) Returns the value associated to the key, or undefined if there is none. Map.prototype.has(key) Returns a boolean asserting whether a value has been associated to the key in the Map object or not. Map.prototype.set(key, value) Sets the value for the key in the Map object. Returns the Map object. Iteration methods Map.prototype[@@
iterator]() Returns a new
Iterator object that contains an array of [key, value] for each element in the Map object in insertion order. Map.prototype.keys() Returns a new
Iterator object that contains the keys for each element in the Map object in insertion order. Map.prototype.values() Returns a new
Iterator object that contains the values for each element in the Map object in insertion order. Map.
... Map.prototype.forEach(callbackFn[, thisArg]) Calls callbackFn once for each key-value pair present in the Map object, in insertion order. ...
...gular Map constructor to transform a 2D key-value Array into a map let myMap = new Map(kvArray) myMap.get('key1') // returns "value1" // Use Array.from() to transform a map into a 2D key-value Array console.log(Array.from(myMap)) // Will show you exactly the same Array as kvArray // A succinct way to do the same, using the spread syntax console.log([...myMap]) // Or use the keys() or values()
iterators, and convert them to an array console.log(Array.from(myMap.keys())) // ["key1", "key2"] Cloning and merging Maps Just like Arrays, Maps can be cloned: let original = new Map([ [1, 'one'] ]) let clone = new Map(original) console.log(clone.get(1)) // one console.log(original === clone) // false (useful for shallow comparison) Important: Keep in mind that the data itself is not clon...
Symbol - JavaScript
y of symbols and lets you find symbol properties on a given object. Note that every object is initialized with no own symbol properties, so that this array will be empty unless you've set symbol properties on the object. Constructor Symbol() Creates a new Symbol object. It is incomplete as a constructor because it does not support the syntax "new Symbol()". Static properties Symbol.async
Iterator A method that returns the default Async
Iterator for an object. Used by for await...of. Symbol.hasInstance A method determining if a constructor object recognizes an object as its instance. Used by instanceof. Symbol.isConcatSpreadable A Boolean value indicating if an object should be flattened to its array elements. Used by Array.prototype.concat(). Symbol.
iterator A method returning the d...
...hod that returns the default Async
Iterator for an object. Used by for await...of. Symbol.hasInstance A method determining if a constructor object recognizes an object as its instance. Used by instanceof. Symbol.isConcatSpreadable A Boolean value indicating if an object should be flattened to its array elements. Used by Array.prototype.concat(). Symbol.
iterator A method returning the default
iterator for an object. Used by for...of. Symbol.match A method that matches against a string, also used to determine if an object may be used as a regular expression. Used by String.prototype.match(). Symbol.matchAll A method that returns an
iterator, that yields matches of the regular expression against a string. Used by String.prototype.matchAll(). Symbol.replace A method that replaces matched su...
...od. Symbol.prototype.valueOf() Returns the primitive value of the Symbol object. Overrides the Object.prototype.valueOf() method. Symbol.prototype[@@toPrimitive] Returns the primitive value of the Symbol object. Examples Using the typeof operator with symbols The typeof operator can help you to identify symbols. typeof Symbol() === 'symbol' typeof Symbol('foo') === 'symbol' typeof Symbol.
iterator === 'symbol' Symbol type conversions Some things to note when working with type conversion of symbols. When trying to convert a symbol to a number, a TypeError will be thrown (e.g. +sym or sym | 0). When using loose equality, Object(sym) == sym returns true. Symbol("foo") + "bar" throws a TypeError (can't convert symbol to string). This prevents you from silently creating a new string p...
Processing XML with E4X - Archive of obsolete content
In a manner akin to DOM tree walkers, we can define our own walkers for E4X. While the following is already achievable by iterating an E4X object with for each...in, it demonstrates how a more customized one could be created. function xmlChildWalker (xml) { var i = 0; ...
... In a manner akin to DOM tree walkers, we can define our own walkers for E4X. While the following is already achievable by iterating an E4X object with for each...in, it demonstrates how a more customized one could be created. function xmlChildWalker (xml) { var i = 0; var child = xml.*[0]; while (child != undefined) { yield child; ...
New in JavaScript 1.7 - Archive of obsolete content
Using JavaScript 1.7 In order to use some of the new features of JavaScript 1.7, you need to specify that you wish to use JavaScript 1.7. ...
...assignment and array comprehensions) can be used without specifying the JavaScript version. New features in JavaScript 1.7 The following features added with JavaScript 1.7 were not part of an ECMA-262 standard at the time. In more recent Firefox versions, the implementation is updated to work with semantics as specified in ECMAScript Edition 6. Please see the reference pages for differences.
Iterators and generators Array comprehensions let statement (support for let expression was dropped in Gecko 41, see bug 1023609). const statement Destructuring assignment (support for JS1.7 style destructuring for-in was dropped in Gecko 40, see bug 1083498). ...
handler.enumerate() - Archive of obsolete content
The handler.enumerate() method used to be a trap for for...in statements, but has been removed from the ECMAScript standard in ES2016 and is deprecated in browsers. Syntax var p = new Proxy(target, { enumerate(target) { } }); Parameters The following parameter is passed to the enumerate method. this is bound to the handler. target The target object. Return value An
iterator object. Description The handler.enumerate method is a trap for for...in statements. Interceptions This trap can intercept these operations: Property enumeration / for...in: for (var name in proxy) {...} Reflect.enumerate() Invariants If the following invariants are violated, the proxy will throw a TypeError: The enumerate method must return an object. Examples The following code traps...
...erations: Property enumeration / for...in: for (var name in proxy) {...} Reflect.enumerate() Invariants If the following invariants are violated, the proxy will throw a TypeError: The enumerate method must return an object. Examples The following code traps for...in statements. var p = new Proxy({}, { enumerate(target) { console.log('called'); return ['a', 'b', 'c'][Symbol.
iterator](); } }); for (var x in p) { // "called" console.log(x); // "a" } // "b" // "c" The following code violates the invariant. var p = new Proxy({}, { enumerate(target) { return 1; } }); for (var x in p) {} // TypeError is thrown Note: Both examples make use of the shorthand syntax for method definitions. Specifications Not part of any standar...
Archived open Web documentation - Archive of obsolete content
grammers can manipulate an XML document with a syntax more familiar to JavaScript programming. Talk:Array.forEach() Ok, in the end I didn't remove the old code as it isn't hosted anywhere (I thought the github reference contained the code) but inserted a faster implementation above while retaining the rest of the document.
Iterator The
Iterator function returns an object which implements legacy
iterator protocol and iterates over enumerable properties of an object. LiveConnect (Please update or remove as needed.) MSX Emulator (jsMSX) Old Proxy API Proxies are objects for which the programmer has to define the semantics ...
...will save you lots of time quality testing your web content. The following authoring tools adhere to the W3 standards. If you're using older versions of tools that rely on old browser bugs or generate browser-specific code, it may be time to upgrade: StopIteration The StopIteration object was used to tell the end of the iteration in the legacy
iterator protocol. Do not use this ancient feature. Styling the Amazing Netscape Fish Cam Page Using JavaScript Generators in Firefox Generators can be used to simplify asynchronous code in Firefox by opting in to using JavaScript version 1.7 or later. You can opt in in HTML as follows: Window.importDialog() Because openin...
Test your skills: Loops - Learn web development
is next task, we want you to write a simple program that, given a name, searches an array of objects containing names and phone numbers (phonebook) and, if it finds the name, outputs the name and phone number into the paragraph (para) and then exits the loop before it has run its course. You are given three variables to begin with: i -- starts off with a value of 0; intended to be used as an
iterator. name -- contains a name to search for para -- contains a reference to a paragraph, which will be used to report the results. You should use a type of loop that you've not used in the previous task. Download the starting point for this task to work in your own editor or in an online editor. Loops 3 In this final task, you are provided with the following: i -- starts off with a value o...
...rch for para -- contains a reference to a paragraph, which will be used to report the results. You should use a type of loop that you've not used in the previous task. Download the starting point for this task to work in your own editor or in an online editor. Loops 3 In this final task, you are provided with the following: i -- starts off with a value of 500; intended to be used as an
iterator. para -- contains a reference to a paragraph, which will be used to report the results. isPrime() -- a function that, when passed a number, returns true if the number is a prime number, and false if not. You need to use a loop to go through the numbers 2 to 500 backwards (1 is not counted as a prime number), and run the provided isPrime() function on them. For each number that isn't a prime n...
Dict.jsm
ey, [optional] Object aDefault); boolean has(String aKey); Array listitems(); Array listkeys(); Array listvalues(); void set(String aKey, Object aValue); String toJSON(); String toString(); Properties Attribute Type Description count Number The number of items in the dictionary. items
Iterator Returns an
iterator over all of the items in the dictionary; each item is returned as a pair (a two-element array) with the first element being the key and the second being the value. Note: The order in which items are returned is arbitrary, and may change without notice. In addition, if the dictionary changes during iteration, no guarantees are made as to what will happen. ...
...urns an
iterator over all of the items in the dictionary; each item is returned as a pair (a two-element array) with the first element being the key and the second being the value. Note: The order in which items are returned is arbitrary, and may change without notice. In addition, if the dictionary changes during iteration, no guarantees are made as to what will happen. keys
Iterator Returns an
iterator over all the keys in the dictionary. Note: The order in which items are returned is arbitrary, and may change without notice. In addition, if the dictionary changes during iteration, no guarantees are made as to what will happen. values
Iterator Returns an
iterator over all the values in the dictionary. Note: The order in which items a...
Task.jsm
running it as a task. Every time the task yields a promise, it waits until the promise is resolved. Task.spawn() returns a promise that is resolved when the task completes successfully, or is rejected if an exception occurs. You can use the yield operator inside the generator function to wait on a promise, spawn another task, or propagate a value: let resolutionValue = yield (promise/generator/
iterator/value); If you specify a promise, the yield operator returns its resolution value as soon as the promise is resolved. If the promise is rejected, its rejection reason is thrown as an exception. If you specify a generator function or the
iterator returned by a generator function, then Task.spawn() is implicitly called, and the yield operator works on the returned promise. This reduces the synt...
...eeting(this.message.replace(/NAME/, name)); }) }; While maintaining identical semantics: greeter.greet("Mitchell").then((reply) => { ... }); // behaves the same spawn() Creates and starts a new task. Promise spawn( aTask ); Parameters aTask This parameter accepts different data types: If you specify a generator function, it is called with no arguments to retrieve the associated
iterator. The generator function is a task, that is can yield promise objects to wait upon. The promise returned by the task either fulfills with the returned value if generator returns or rejects with the thrown error if the generator throws. If you specify the
iterator returned by a generator function you called, the generator function is also executed as a task. This allows you to call the function w...
JSExtendedClass
ass is an extended version of JSClass with additional hooks. A C/C++ program can use a JSExtendedClass with the JS_InitClass and JS_NewObject APIs to create objects that have custom methods and properties implemented in C/C++. Syntax struct JSExtendedClass { JSClass base; JSEqualityOp equality; JSObjectOp outerObject; JSObjectOp innerObject; JS
IteratorOp
iteratorObject;// Added in SpiderMonkey 1.8 JSObjectOp wrappedObject; // Added in SpiderMonkey 1.8 ...and additional reserved fields. }; Name Type Description base JSClass The basic class information and callbacks for this class. This contains some required fields. equality JSEqualityOp Optional. Overrides the JavaScript == an...
...s for this class. This contains some required fields. equality JSEqualityOp Optional. Overrides the JavaScript == and != operators. outerObject JSObjectOp Optional. Return the current outer object. This is used to implement split objects. innerObject JSObjectOp Optional. Return the current inner object. This is used to implement split objects.
iteratorObject JS
IteratorOp Added in SpiderMonkey 1.8 Optional. Creates and returns a new
iterator. wrappedObject JSObjectOp Added in SpiderMonkey 1.8 Optional. If non-null, an object of this class may serve as a wrapper for another object. Wrappers sometimes transparently behave like the object they wrap. For example, an object and its wrappers are all equal under ===. Descript...
JSNewEnumerateOp
ewEnumerateOp in a JSClass, set the JSCLASS_NEW_ENUMERATE bit in the JSClass.flags field and set the JSClass.enumerate field to your JSNewEnumerateOp, casting it to JSEnumerateOp. (SpiderMonkey, noting the JSCLASS_NEW_ENUMERATE flag, will cast that function pointer back to type JSNewEnumerateOp before calling it.) The behavior depends on the value of enum_op: JSENUMERATE_INIT A new, opaque
iterator state should be allocated and stored in *statep. (You can use PRIVATE_TO_JSVAL to tag the pointer to be stored). The number of properties that will be enumerated should be returned as an integer jsval in *idp, if idp is non-null, and provided the number of enumerable properties is known. If idp is non-null and the number of enumerable properties can't be computed in advance, *idp should be set ...
...sval in *idp, if idp is non-null, and provided the number of enumerable properties is known. If idp is non-null and the number of enumerable properties can't be computed in advance, *idp should be set to JSVAL_ZERO. JSENUMERATE_INIT_ALL Used identically to JSENUMERATE_INIT, but exposes all properties of the object regardless of enumerability. JSENUMERATE_NEXT A previously allocated opaque
iterator state is passed in via statep. Return the next jsid in the iteration using *idp. The opaque
iterator state pointed at by statep is destroyed and *statep is set to JSVAL_NULL if there are no properties left to enumerate. JSENUMERATE_DESTROY Destroy the opaque
iterator state previously allocated in *statep by a call to this function when enum_op was JSENUMERATE_INIT or JSENUMERATE_INIT_ALL. ...
JSDBGAPI
_ClearTrap JS_ClearScriptTraps JS_ClearAllTraps JS_HandleTrap JS_SetInterrupt JS_ClearInterrupt Watchpoints JS_SetWatchPoint JS_ClearWatchPoint JS_ClearWatchPointsForObject JS_ClearAllWatchPoints Inspecting the stack JS_PCToLineNumber JS_LineNumberToPC JS_GetFunctionScript JS_GetFunctionNative JS_GetFunctionFastNative JS_GetScriptPrincipals typedef JSStackFrame JS_Frame
Iterator JS_GetFrameScript JS_GetFramePC JS_GetScriptedCaller JS_StackFramePrincipals JS_EvalFramePrincipals JS_GetFrameAnnotation JS_SetFrameAnnotation JS_GetFramePrincipalArray JS_IsNativeFrame JS_GetFrameObject JS_GetFrameScopeChain JS_GetFrameCallObject JS_GetFrameThis JS_GetFrameFunction JS_GetFrameFunctionObject JS_IsConstructorFrame JS_IsDebuggerFrame JS_GetFrameReturnValue JS_...
...ameFlags JS_GetScriptFilenameFlags JS_FlagScriptFilenamePrefix JSFILENAME_NULL JSFILENAME_SYSTEM JSFILENAME_PROTECTED Evaluating debug code JS_EvaluateInStackFrame Examining object properties typedef JSPropertyDesc JSPD_ENUMERATE JSPD_READONLY JSPD_PERMANENT JSPD_ALIAS JSPD_ARGUMENT JSPD_VARIABLE JSPD_EXCEPTION JSPD_ERROR typedef JSPropertyDescArray JS_Property
Iterator JS_GetPropertyDesc JS_GetPropertyDescArray JS_PutPropertyDescArray Hooks JS_SetDebuggerHandler JS_SetSourceHandler JS_SetExecuteHook JS_SetCallHook JS_SetObjectHook JS_SetThrowHook JS_SetDebugErrorHook JS_SetNewScriptHook JS_SetDestroyScriptHook JS_GetGlobalDebugHooks JS_SetContextDebugHooks Memory usage JS_GetObjectTotalSize JS_GetFunctionTotalSize JS_GetScriptTotalSi...
SpiderMonkey 1.8
. Please let us know about your experiences with this release by posting in the mozilla.dev.tech.js-engine newsgroup. Or, file bugs at bugzilla.mozilla.org under Product: Core, Component: JavaScript engine. --9 March 2009 Known issues SpiderMonkey 1.8 has one known significant regression from 1.7. In JS_THREADSAFE builds, some objects are not safe to be shared among threads. This includes
iterators and generators (bug 349263) and arrays (bug 417501). In short, applications that share objects among threads in such a way that two threads could access an array,
iterator, or generator object at the same time should not use SpiderMonkey 1.8. There is a minor known bug in the new JavaScript 1.8 functionality. When JavaScript 1.8 support is enabled, the parser accepts some incorrect progra...
...nctions from appearing anyplace where a statement could appear, such as in the argument to eval(). Functions that were JS_THREADSAFE-only in SpiderMonkey 1.7 (JS_BeginRequest, for example) are now present, but do nothing, in non-JS_THREADSAFE builds. This is to help applications share and reuse code regardless of whether they use threads. There are two new JSExtendedClass hooks, JSExtendedClass.
iteratorObject and JSExtendedClass.wrappedObject. Both are documented but obscure. Many new memory management features have been added as well. The new function JS_SetScriptStackQuota limits the size of the JavaScript stack. Two new functions, JS_SetGCZeal and JS_DumpHeap, aim to help developers debug GC-related problems. These functions are only present in DEBUG builds. JS_SetGCZeal is especially h...
NS_ConvertUTF16toUTF8
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
NS_LossyConvertUTF16toASCII
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsAdoptingCString
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsCString
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsDependentCString
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsFixedCString
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsPromiseFlatCString
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsXPIDLCString
to this string Parameters PRUint32 aInteger PRInt32 aRadix void AppendInt(PRInt64, PRInt32) - source Parameters PRInt64 aInteger PRInt32 aRadix AppendFloat void AppendFloat(float) - source Append the given float to this string Parameters float aFloat void AppendFloat(double) - source Parameters double aFloat BeginReading char* BeginReading() const - source reading
iterators nsReading
Iterator<char>& BeginReading(nsReading
Iterator<char>&) const - source deprecated reading
iterators Parameters nsReading
Iterator<char>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<ch...
...ar>& iter char*& BeginReading(const char*&) const - source Parameters char*& iter EndReading char* EndReading() const - source nsReading
Iterator<char>& EndReading(nsReading
Iterator<char>&) const - source Parameters nsReading
Iterator<char>& iter char*& EndReading(const char*&) const - source Parameters char*& iter BeginWriting char* BeginWriting() - source writing
iterators nsWriting
Iterator<char>& BeginWriting(nsWriting
Iterator<char>&) - source deprecated writing
iterators Parameters nsWriting
Iterator<char>& iter char*& BeginWriting(char*&) - source Parameters char*& iter EndWriting char* EndWriting() - source nsWriting
Iterator<char>& EndWriting(nsWriting
Iterator<char>&) - source Parameters nsWriting
Iterator<char>& iter char*& EndWriting...
nsIDNSRecord
RUint16 aPort); Native code only! ACString getNextAddrAsString(); boolean hasMore(); void rewind(); Attributes Attribute Type Description canonicalName ACString for example, www.mozilla.org --> rheet.mozilla.org. Read only. Methods Native code only!getNextAddr This function copies the value of the next IP address into the given PRNetAddr struct and increments the internal address
iterator. PRNetAddr getNextAddr( in PRUint16 aPort ); Parameters aPort A port number to initialize the PRNetAddr with. Return value The value of the next IP address. getNextAddrAsString() This function returns the value of the next IP address as a string and increments the internal address
iterator. ACString getNextAddrAsString(); Parameters None. Return value The value of the next IP address as a s...
... IP address as a string and increments the internal address
iterator. ACString getNextAddrAsString(); Parameters None. Return value The value of the next IP address as a string. hasMore() This method checks if there is another address in the record. boolean hasMore(); Parameters None. Return value true if there is another address in the record. rewind() This function resets the internal address
iterator to the first address in the record. void rewind(); Parameters None. ...
nsIXPCScriptable
ctPtr obj, in PRUint32 enum_op, in JSValPtr statep, out JSID idp ); Parameters wrapper cx The pointer to the JSContext newEnumerate is being called from. obj The pointer to the JSObject being enumerated. enum_op Indicates what statep and idp represent, as well as indicates how the function should behave. This will always be one of three values: JSENUMERATE_INIT A new, opaque
iterator state should be allocated and stored in statep. You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored. If idp is non-null, and provided the number of enumerable properties is known, the number of properties that will be enumerated should be returned as an integer jsval in idp. If idp is non-null and the number of enumerable properties cannot be computed in advance, idp should be set to...
...f idp is non-null, and provided the number of enumerable properties is known, the number of properties that will be enumerated should be returned as an integer jsval in idp. If idp is non-null and the number of enumerable properties cannot be computed in advance, idp should be set to JSVAL_ZERO. Your function might be passed a null pointer for idp. JSENUMERATE_NEXT A previously allocated opaque
iterator state is passed in via statep. Return the next jsid in the iteration using idp. The opaque
iterator state pointed at by statep is destroyed and *statep is set to JSVAL_NULL if there are no properties left to enumerate. JSENUMERATE_DESTROY This function should destroy the opaque
iterator state previously allocated in statep by this function when enum_op was JSENUMERATE_INIT. statep An in/out...
DOMTokenList.entries() - Web APIs
The DOMTokenList.entries() method returns an
iterator allowing you to go through all key/value pairs contained in this object. The values are DOMString objects, each representing a single token. Syntax tokenList.entries(); Return value Returns an
iterator. Examples In the following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the key/value pairs using entries(), then iterate through each one using a for...of loop, writing them to the <span>'s Node.textContent. ...
...f classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the key/value pairs using entries(), then iterate through each one using a for...of loop, writing them to the <span>'s Node.textContent. First, the HTML: <span class="a b c"></span> Now the JavaScript: let span = document.querySelector("span"); let classes = span.classList; let
iterator = classes.entries(); for (let value of
iterator) { span.textContent += value + ' ++ '; } The output looks like this: Specifications Specification Status Comment DOMThe definition of 'entries() (as iterable<Node>)' in that specification. Living Standard Initial definition. ...
DOMTokenList.forEach() - Web APIs
the array. currentIndex The index of the current element being processed in the array. listObj The array that forEach() is being applied to. thisArg Optional Value to use as this when executing callback. Return value undefined. Example In the following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList. ...
...he following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the values using forEach(), writing each one to the <span>'s Node.textContent inside the forEach() inner function. ...
DOMTokenList.keys() - Web APIs
The keys() method of the DOMTokenList interface returns an
iterator allowing to go through all keys contained in this object. The keys are of type unsigned integer. Syntax tokenList.keys(); Parameters None. Return value Returns an
iterator. Examples In the following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the keys using values(), then iterate through those keys using a for ... of loop, writing each one to the <span>'s Node.textContent. ...
...st of classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the keys using values(), then iterate through those keys using a for ... of loop, writing each one to the <span>'s Node.textContent. First, the HTML: <span class="a b c"></span> Now the JavaScript: var span = document.querySelector("span"); var classes = span.classList; var
iterator = classes.keys(); for(var value of
iterator) { span.textContent += value + ' ++ '; } The output looks like this: Specifications Specification Status Comment DOMThe definition of 'keys() (as iterable<Node>)' in that specification. Living Standard Initial definition ...
DOMTokenList.values() - Web APIs
The values() method of the DOMTokenList interface returns an
iterator allowing developers to go through all values contained in the DOMTokenList. The individual values are DOMString objects. Syntax tokenList.values(); Parameters None. Return value Returns an
iterator. Examples In the following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the values using values(), then iterate through those values using a for ... of loop, writing each one to the <span>'s Node.textContent. ...
...f classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an
iterator containing the values using values(), then iterate through those values using a for ... of loop, writing each one to the <span>'s Node.textContent. First, the HTML: <span class="a b c"></span> Now the JavaScript: var span = document.querySelector("span"); var classes = span.classList; var
iterator = classes.values(); for(var value of
iterator) { span.textContent += value + ' ++ '; } The output looks like this: Specifications Specification Status Comment DOMThe definition of 'values() (as iterable<Node>)' in that specification. Living Standard Initial definition ...
DOMTokenList - Web APIs
oldToken, newToken) Replaces token with newToken. DOMTokenList.supports(token) Returns true if a given token is in the associated attribute's supported tokens. DOMTokenList.toggle(token [, force]) Removes token from the list if it exists, or adds token to the list if it doesn't. Returns a boolean indicating whether token is in the list after the operation. ...
...if it exists, or adds token to the list if it doesn't. Returns a boolean indicating whether token is in the list after the operation. DOMTokenList.entries() Returns an
iterator, allowing you to go through all key/value pairs contained in this object. DOMTokenList.forEach(callback [, thisArg]) Executes a provided callback function once per DOMTokenList element. DOMTokenList.keys() Returns an
iterator, allowing you to go through all keys of the key/value pairs contained in this object. DOMTokenList.values() Returns an
iterator, allowing you to go through all values of the key/value pairs contained in this object. Examples In the following simple example, we retrieve the list of classes set on a <p> element as a DOMTokenList using Element.classList, add a class using DOMTokenList.add(), an...
Using Fetch - Web APIs
, result); }) .catch(error => { console.error('Error:', error); }); Processing a text file line by line The chunks that are read from a response are not broken neatly at line boundaries and are Uint8Arrays, not strings. If you want to fetch a text file and process it line by line, it is up to you to handle these complications. The following example shows one way to do this by creating a line
iterator (for simplicity, it assumes the text is UTF-8, and doesn't handle fetch errors). async function* makeTextFileLine
Iterator(fileURL) { const utf8Decoder = new TextDecoder('utf-8'); const response = await fetch(fileURL); const reader = response.body.getReader(); let { value: chunk, done: readerDone } = await reader.read(); chunk = chunk ? utf8Decoder.decode(chunk) : ''; const re = /\n|...
...An accurate check for a successful fetch() would include check...
FormData - Web APIs
ent to for (var p of myFormData.entries()). Note: This feature is available in Web Workers. Constructor FormData() Creates a new FormData object. Methods FormData.append() Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. FormData.delete() Deletes a key/value pair from a FormData object. FormData.entries() Returns an
iterator allowing to go through all key/value pairs contained in this object. FormData.get() Returns the first value associated with a given key from within a FormData object. FormData.getAll() Returns an array of all the values associated with a given key from within a FormData. FormData.has() Returns a boolean stating whether a FormData object contains a certain key. FormData.keys() Returns an i...
... from within a FormData. FormData.has() Returns a boolean stating whether a FormData object contains a certain key. FormData.keys() Returns an
iterator allowing to go through all keys of the key/value pairs contained in this object. FormData.set() Sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist. FormData.values() Returns an
iterator allowing to go through all values contained in this object. Specifications Specification Status Comment XMLHttpRequestThe definition of 'FormData' in that specification. Living Standard FormData defined in XHR spec ...
Headers - Web APIs
s()). Note: you can find more out about the available headers by reading our HTTP headers reference. Constructor Headers() Creates a new Headers object. Methods Headers.append() Appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist. Headers.delete() Deletes a header from a Headers object. ...
...an
iterator allowing to go through all key/value pairs contained in this object. Headers.forEach() Executes a provided function once for each array element. Headers.get() Returns a ByteString sequence of all the values of a header within a Headers object with a given name. Headers.has() Returns a boolean stating whether a Headers object contains a certain header. Headers.keys() Returns an
iterator allowing you to go through all keys of the key/value pairs contained in this object. Headers.set() Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist. Headers.values() Returns an
iterator allowing you to go through all values of the key/value pairs contained in this object. Note: To be clear, the difference between Headers.set()...
KeyboardLayoutMap.keys - Web APIs
Syntax
iterator = KeyboardLayoutMap.keys Value An
iterator. ...
... The keys read-only property of the KeyboardLayoutMap interface returns a new Array
Iterator object that contains the keys for each index in the array. Syntax
iterator = KeyboardLayoutMap.keys Value An
iterator. Specifications Specification Status Comment Keyboard MapThe definition of 'keys' in that specification. Editor's Draft Initial definition. ...
KeyboardLayoutMap.values - Web APIs
Syntax var
iterator = KeyboardLayoutMap.values Value An
iterator. ...
... The values read-only property of the KeyboardLayoutMap interface returns a new Array
Iterator object that contains the values for each index in the map. Syntax var
iterator = KeyboardLayoutMap.values Value An
iterator. Specifications Specification Status Comment Keyboard MapThe definition of 'values' in that specification. Editor's Draft Initial definition. ...
MediaKeyStatusMap - Web APIs
The MediaKeyStatusMap interface of the EncryptedMediaExtensions API is a read-only map of media key statuses by key IDs. Properties MediaKeyStatusMap.size Read only Returns the number of key/value pars in the status map. Methods MediaKeyStatusMap.entries() Read only Returns a new
Iterator object containing an array of [key, value] for each element in the status map, in insertion order. MediaKeyStatusMap.forEach(callback[, argument]) Read only Calls callback once for each key-value pair in the status map, in insertion order. If argument is present it will be passed to the callback. MediaKeyStatusMap.get() Read only Returns the value associated with the given key, or undefined if there is none. MediaKeyStatusMap.has() Read only Returns a boolean asserting whether a value has...
...y-value pair in the status map, in insertion order. If argument is present it will be passed to the callback. MediaKeyStatusMap.get() Read only Returns the value associated with the given key, or undefined if there is none. MediaKeyStatusMap.has() Read only Returns a boolean asserting whether a value has been associated with the given key. MediaKeyStatusMap.keys() Read only Returns a new
Iterator object containing keys for each element in the status map, in insertion order. MediaKeyStatusMap.values() Read only Returns a new
Iterator object containing values for each element in the status map, in insertion order. MediaKeyStatusMap.[@@
iterator]() Read only Returns a new
Iterator object containing an array of [key, value] for each element in the status map, in insertion order. Specif...
ReadableStream - Web APIs
ject from the given handlers. Properties ReadableStream.locked Read only The locked getter returns whether or not the readable stream is locked to a reader. Methods ReadableStream.cancel() Cancels the stream, signaling a loss of interest in the stream by a consumer. The supplied reason argument will be given to the underlying source, which may or may not use it. ReadableStream.get
Iterator() Creates a ReadableStream async
iterator instance and locks the stream to it. While the stream is locked, no other reader can be acquired until this one is released. ReadableStream.getReader() Creates a reader and locks the stream to it. While the stream is locked, no other reader can be acquired until this one is released. ReadableStream.pipeThrough() Provides a chainable way of piping ...
...am to a given WritableStream and returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. ReadableStream.tee() The tee method tees this readable stream, returning a two-element array containing the two resulting branches as new ReadableStream instances. Each of those streams receives the same incoming data. ReadableStream[@@async
Iterator]() Alias of get
Iterator method. Examples In the following example, an artificial Response is created to stream HTML fragments fetched from another resource to the browser. It demonstrates the usage of a ReadableStream in combination with a Uint8Array. fetch("https://www.example.org/").then((response) => { const reader = response.body.getReader(); const stream = new ReadableStream({ ...
ReadableStreamDefaultReader.read() - Web APIs
tem); result += chunk; // Read some more, and call this function again return reader.read().then(processText); }); } Example 2 - handling text line by line This example shows how you might fetch a text file and handle it as a stream of text lines. It deals with stream chunks not ending on line boundaries and converting from Uint8Array to strings. ...
... Living Standard Initial definition. ...
XRInputSourceArray.values() - Web APIs
Examples This example snippet walks through each input and calls the function checkInput() with each returned value. for (const source of xrSession.inputSources.values()) { checkInput(source); } Here, for...of is used to iterate over the array's contents. ...
...ed to iterate over the array's contents. Each pass through the loop, source is the next XRInputSource in the list. The loop exits once every input has been delivered to checkInput(). Specifications Specification Status Comment WebXR Device APIThe definition of 'XRInputSourceArray' in that specification.1 Working Draft XRInputSourceArray interface [1] See
Iterator-like methods in Information contained in a WebIDL file for information on how an iterable declaration in an interface definition causes entries(), forEach(), keys(), and values() methods to be exposed from objects that implement the interface. ...
Array.prototype.keys() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax arr.keys() Return value A new Array
iterator object. ...
... The keys() method returns a new Array
Iterator object that contains the keys for each index in the array. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax arr.keys() Return value A new Array
iterator object. Examples Key
iterator doesn't ignore holes var arr = ['a', , 'c']; var sparseKeys = Object.keys(arr); var denseKeys = [...arr.keys()]; console.log(sparseKeys); // ['0', '2'] console.log(denseKeys); // [0, 1, 2] Specifications Specification ECMAScript (ECMA-262)The definition of 'Array.prototype.keys' in that specification. ...
Generator - JavaScript
The Generator object is returned by a generator function and it conforms to both the iterable protocol and the
iterator protocol. Constructor This object cannot be instantiated directly. Instead, a Generator instance can be returned from a generator function: function* generator() { yield 1; yield 2; yield 3; } const gen = generator(); // "Generator { }" Instance methods Generator.prototype.next() Returns a value yielded by the yield expression. Generator.prototype.return() Returns the given value and finishes the generator. Generator.prototype.throw() Throws an error to a generator (also finishes the generator, unless caught from within that generator). ...
...2; yield 3; } const gen = generator(); // "Generator { }" Instance methods Generator.prototype.next() Returns a value yielded by the yield expression. Generator.prototype.return() Returns the given value and finishes the generator. Generator.prototype.throw() Throws an error to a generator (also finishes the generator, unless caught from within that generator). Examples An infinite
iterator function* infinite() { let index = 0; while (true) { yield index++; } } const generator = infinite(); // "Generator { }" console.log(generator.next().value); // 0 console.log(generator.next().value); // 1 console.log(generator.next().value); // 2 // ... Specifications Specification ECMAScript (ECMA-262)The definition of 'Generator objects' in that speci...
Map.prototype.entries() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap.entries() Return value A new Map
iterator object. ...
... returns a new
Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap.entries() Return value A new Map
iterator object. Examples Using entries() let myMap = new Map() myMap.set('0', 'foo') myMap.set(1, 'bar') myMap.set({}, 'baz') let mapIter = myMap.entries() console.log(mapIter.next().value) // ["0", "foo"] console.log(mapIter.next().value) // [1, "bar"] console.log(mapIter.next().value) // [Object, "baz"] Specifications Specification ECMAScript (ECMA-262)The definition of...
Map.prototype.keys() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap.keys() Return value A new Map
iterator object. ...
...The keys() method returns a new
Iterator object that contains the keys for each element in the Map object in insertion order. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap.keys() Return value A new Map
iterator object. Examples Using keys() var myMap = new Map(); myMap.set('0', 'foo'); myMap.set(1, 'bar'); myMap.set({}, 'baz'); var mapIter = myMap.keys(); console.log(mapIter.next().value); // "0" console.log(mapIter.next().value); // 1 console.log(mapIter.next().value); // Object Specifications Specification ECMAScript (ECMA-262)The definition of 'Map.prototype.keys' in that sp...
Map.prototype.values() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap.values() Return value A new Map
iterator object. ...
...lues() method returns a new
Iterator object that contains the values for each element in the Map object in insertion order. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax myMap.values() Return value A new Map
iterator object. Examples Using values() var myMap = new Map(); myMap.set('0', 'foo'); myMap.set(1, 'bar'); myMap.set({}, 'baz'); var mapIter = myMap.values(); console.log(mapIter.next().value); // "foo" console.log(mapIter.next().value); // "bar" console.log(mapIter.next().value); // "baz" Specifications Specification ECMAScript (ECMA-262)The definition of 'Map.prototype.values' ...
RegExp.prototype[@@matchAll]() - JavaScript
all matches of the regular expression against a string. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax regexp[Symbol.matchAll](str) Parameters str A String that is a target of the match. Return value An
iterator. Description This method is called internally in String.prototype.matchAll(). For example, the following two examples return same result. 'abc'.matchAll(/a/); /a/[Symbol.matchAll]('abc'); This method exists for customizing the behavior of matchAll() in RegExp subclasses. Examples Direct call This method can be used in almost the same way as String.prototype.matchAll(), except for the diff...
...ept for the different value of this and the different order of arguments. let re = /[0-9]+/g; let str = '2016-01-02'; let result = re[Symbol.matchAll](str); console.log(Array.from(result, x => x[0])); // ["2016", "01", "02"] Using @@matchAll in subclasses Subclasses of RegExp can override the [@@matchAll]() method to modify the default behavior. ...
Set - JavaScript
the Set object. Set.prototype.delete(value) Removes the element associated to the value and returns the value that Set.prototype.has(value) would have previously returned. Set.prototype.has(value) will return false afterwards. Set.prototype.has(value) Returns a boolean asserting whether an element is present with the given value in the Set object or not. Iteration methods Set.prototype[@@
iterator]() Returns a new
Iterator object that yields the values for each element in the Set object in insertion order. Set.prototype.keys() Returns a new
Iterator object that yields the values for each element in the Set object in insertion order. (For Sets, this is the same as the values() method.) Set.prototype.values() Returns a new
Iterator object that yields the values for each element in the S...
... This is similar to the Map object, so that each entry's key is the same as its value for a Set. Set.prototype.forEach(callbackFn[, thisArg]) Calls callbackFn once for each value present in the Set object, in insertion order. ...
String - JavaScript
ccurrence of searchValue, or -1 if not found. String.prototype.localeCompare(compareString [, locales [, options]]) Returns a number indicating whether the reference string compareString comes before, after, or is equivalent to the given string in sort order. String.prototype.match(regexp) Used to match regular expression regexp against a string. String.prototype.matchAll(regexp) Returns an
iterator of all regexp's matches. String.prototype.normalize([form]) Returns the Unicode Normalization Form of the calling string value. String.prototype.padEnd(targetLength [, padString]) Pads the current string from the end with a given string and returns a new string of the length targetLength. String.prototype.padStart(targetLength [, padString]) Pads the current string from the start with a giv...
...rims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard. String.prototype.trimStart() Trims whitespace from the beginning of the string. String.prototype.trimEnd() Trims whitespace from the end of the string. String.prototype.valueOf() Returns the primitive value of the specified object. Overrides the Object.prototype.valueOf() method. String.prototype.@@
iterator() Returns a new
Iterator object that iterates over the code points of a String value, returning each code point as a String value. HTML wrapper methods Deprecated. Avoid these methods. They are of limited use, as they provide only a subset of the available HTML tags and attributes. String.prototype.anchor() <a name="name"> (hypertext target) String.prototype.big() <big> String.prot...
TypedArray.prototype.entries() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax arr.entries() Return value A new Array
Iterator object. ...
... The entries() method returns a new Array
iterator object that contains the key/value pairs for each index in the array. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax arr.entries() Return value A new Array
Iterator object. Examples Iteration using for...of loop var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArray = arr.entries(); // your browser must support for..of loop // and let-scoped variables in for loops for (let n of eArray) { console.log(n); } Alternative iteration var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArr = arr.entries(); console.log(eArr.next().value); // [0, 10] consol...
for await...of - JavaScript
terables, including: built-in String, Array, Array-like objects (e.g., arguments or NodeList), TypedArray, Map, Set, and user-defined async/sync iterables. It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object. Like the await operator, the statement can only be used inside an async function. for await...of doesn't work with async
iterators that are not async iterables. Syntax for await (variable of iterable) { statement } variable On each iteration a value of a different property is assigned to variable. variable may be declared with const, let, or var. iterable Object whose iterable properties are to be iterated over. Examples Iterating over async iterables You can also iterate over an object that explicitly imple...
...le) { statement } variable On each iteration a value of a different property is assigned to variable. variable may be declared with const, let, or var. iterable Object whose iterable properties are to be iterated over. ...
function* - JavaScript
n JavaScript -- especially when combined with Promises -- are a very powerful tool for asynchronous programming as they mitigate -- if not entirely eliminate -- the problems with callbacks, such as Callback Hell and Inversion of Control. However, an even simpler solution to these problems can be achieved with async functions. Calling a generator function does not execute its body immediately; an
iterator object for the function is returned instead. When the
iterator's next() method is called, the generator function's body is executed until the first yield expression, which specifies the value to be returned from the
iterator or, with yield*, delegates to another generator function. The next() method returns an object with a value property containing the yielded value and a done property which ind...
...o { *generator () { yield 1; yield 2; yield 3; } } const f = new Foo (); const gen = f.generator(); console.log(gen.next()); // { value: 1, done: false } console.log(gen.next()); // { value: 2, done: false } console.log(gen.next()); // { value: 3, done: false } console.log(gen.next()); // { value: undefined, done: true } Generator as a computed property class Foo { *[Symbol.
iterator] () { yield 1; yield 2; } } const SomeObj = { *[Symbol.
iterator] () { yield 'a'; yield 'b'; } } console.log(Array.from(new Foo)); // [ 1, 2 ] console.log(Array.from(SomeObj)); // [ 'a', 'b' ] Generators are not constructable function* f() {} var obj = new f; // throws "TypeError: f is not a constructor Generator defined in an expression const foo = function* () { y...
Statements and declarations - JavaScript
specifies a response, should an exception be thrown. Declarations var Declares a variable, optionally initializing it to a value. let Declares a block scope local variable, optionally initializing it to a value. const Declares a read-only named constant. Functions and classes function Declares a function with the specified parameters. function* Generator Functions enable writing
iterators more easily. async function Declares an async function with the specified parameters. return Specifies the value to be returned by a function. class Declares a class. Iterations do...while Creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement execut...
...ment executed in the loop. for each...in Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed. for...in Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed. for...of Iterates over iterable objects (including arrays, array-like objects,
iterators and generators), invoking a custom iteration hook with statements to be executed for the value of each distinct property. for await...of Iterates over async iterable objects, array-like objects,
iterators and generators, invoking a custom iteration hook with statements to be executed for the value of each distinct property. while Creates a loop that executes a specified statement as long as ...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
ptr->GetterMethod(getter_Copies(value)); - const PRUnichar *strvalue = value; + // nsString doesn't cast directly to PRUnichar*, use .get()+ const PRUnichar *strvalue = value.get(); The frozen string API doesn't accept a length for .Truncate(). Use .SetLength() instead: nsString myString = someString; - myString.Truncate(4); + myString.SetLength(4); The frozen string API doesn't support the
iterator or const_
iterator classes, but you can use pointers the same way: nsString myString = someString; - nsString::const_
iterator begin, end;- myString.BeginReading(begin); myString.EndReading(end); + const PRUnichar *begin, *end;+ myString.BeginReading(&begin, &end); The frozen string API uses comparator functions instead of a virtual comparator class. unicharutils has been modified to provide a f...
Chapter 4: Using XPCOM—Implementing advanced processes - Archive of obsolete content
in Firefox and then close them. Listing 5: Closing all browser windows var browsers = WindowMediator.getEnumerator('navigator:browser'); var browser; while (browsers.hasMoreElements()) { browser = browsers.getNext().QueryInterface(Components.interfaces.nsIDOMWindowInternal); browser.BrowserTryToCloseWindow(); } This method returns an overview of the specified window type in the form of an
Iterator pattern object called nsISimpleEnumerator. After getting an element with the nsISimpleEnumerator.getNext() method, use the QueryInterface method to get the interface, which allows you to handle each element as a window object. Like the getMostRecentWindow() method, passing null as the parameter for the getEnumerator() method enables you to get all windows in Firefox, including dialogs, etc. Man...
Promises - Archive of obsolete content
= info.lastModificationDate; // Read the file as a UTF-8 string, parse as JSON. let config = JSON.parse( yield OS.File.read(configPath, { encoding: "utf-8" })); let files = []; // Get the directory contents from a list of directories. for (let dir of config.directories) { // Iterate over the contents of the directory. let iter = new OS.File.Directory
Iterator(dir); yield iter.forEach(entry => { if (!entry.isDir) files.push(entry.path); }); iter.close(); } // Read the files as binary blobs and process them. let processor = new FileProcessor(); for (let file of files) { let data = yield OS.File.read(file); processor.add(data); } // Now write the processed files...
Search Extension Tutorial (Draft) - Archive of obsolete content
ine name. // An engine with this name must already exist. setPref("browser.search.defaultenginename", "Example Engine", true); } function shutdown(data, reason) { // No need to do this if this is app shutdown. if (reason == APP_SHUTDOWN) return; // Reset our changes if the values have not been changed // in the meantime. ...
Index of archived content - Archive of obsolete content
Displaying notifications (deprecated) E4X E4X for templating Processing XML with E4X E4X Tutorial Accessing XML children Descendants and Filters Introduction Namespaces The global XML object
Iterator LiveConnect LiveConnect Overview LiveConnect Reference JSException JSObject MSX Emulator (jsMSX) Old Proxy API ParallelArray Properly Using CSS and JavaScript in XHTML Documents ...
Documentation for BiDi Mozilla - Archive of obsolete content
the base level (direction) of the paragraph.nextBidi: when a frame has been split, this points to the next frame (in logical order). It is an nsContinuingTextFrame. "Reordering" of frames is accomplished by setting the appropriate frame coordinates. The order of the frames in the content model is not affected, so frames that are adjacent in the content model can be far apart visually. A new frame
iterator, nsVisual
Iterator (in nsFrameTraversal.cpp) provides visual frame navigation capability. Details of rendering are dependent on user preferences and system capabilities. Where the system is capable of tasks such as reversing and shaping text, symmetric swapping, numeric translation, etc., no special text rendering is needed, though there may be a call to a native API to set the base text direction...
Table Cellmap - Archive of obsolete content
e not caused by zero spans, this is at least a O2(n) algorithm. The following routines seem to be hot spots performance wise: nsCellMap::ColHasSpanningCells nsCellMap::RowHasSpanningCells nsCellMap::RowIsSpannedInto Users of nsCellmap::GetDataAt outside nsCellMap.cpp The border collapse code relies on the cellmap. The collapsing of rows and columns uses the cellmap. and finally the line
iterator methods which are used for arrow navigation through a table. Original Document Information Author(s): Bernd Mielke Last Updated Date: September 27, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by individual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Treehydra Manual - Archive of obsolete content
e modified in place. Thus, it is not currently possible to get both GIMPLE ASTs and CFGs in the same run of Treehydra. require({ after_gcc_pass: "cfg" }); include('gcc_util.js'); // for function_decl_cfg include('gcc_print.js'); function process_tree(fn) { print("function " + decl_name(fn)); // fn is a FUNCTION_DECL let cfg = function_decl_cfg(fn); for (let bb in cfg_bb_
iterator(cfg)) { print(" basic block " + bb_label(cfg, bb)); for (let isn in bb_isn_
iterator(bb)) { print(" " + isn_display(isn)); } } } Post-Inlining GIMPLE CFGs Treehydra can be positioned after any pass, allowing you access various levels of GIMPLE. In this example, we show how to access the GIMPLE just after function inlining is performed. (This all...
Array comprehensions - Archive of obsolete content
% 2 === 0) i * 2]; console.log(doubledEvens); // logs 4,44,60 The square brackets of an array comprehension introduce an implicit block for scoping purposes. New variables (such as i in the example) are treated as if they had been declared using let. This means that they will not be available outside of the comprehension. The input to an array comprehension does not itself need to be an array;
iterators and generators can also be used. Even strings may be used as input; to achieve the filter and map actions (under Array-like objects) above: var str = 'abcdef'; var consonantsOnlyStr = [for (c of str) if (!(/[aeiouAEIOU]/).test(c)) c].join(''); // 'bcdf' var interpolatedZeros = [for (c of str) c + '0' ].join(''); // 'a0b0c0d0e0f0' Again, the input form is not preserved, so we have to use join...
Legacy generator function expression - Archive of obsolete content
unction name. Can be omitted, in which case the function is anonymous. The name is only local to the function body. paramN The name of an argument to be passed to the function. A function can have up to 255 arguments. statements The statements which comprise the body of the function. This should contain at least one yield expression. Description An overview of the usage is available on the
Iterators and Generators page. ...
Legacy generator function - Archive of obsolete content
ssion. Syntax function name([param,[, param,[..., param]]]) { [statements] } name The function name. param The name of an argument to be passed to the function. A function can have up to 255 arguments. statements The statements which comprise the body of the function. This should contain at least one yield expression. Description An overview of the usage is available on the
Iterators and Generators page. ...
New in JavaScript 1.8 - Archive of obsolete content
ges in destructuring for..in One change that occurred in the release of JavaScript 1.8 was a bug fix related to the key/value destructuring of arrays introduced in JavaScript 1.7. Previously it was possible to destructure the keys/values of an array by using for ( var [key, value] in array ). However, that made it impossible to destructure the values of an array - that were arrays (i.e., when an
iterator returns an array of the current key-value pair). This has been resolved now. (bug 366941). One can, however, use for ( var [key, value] in
Iterator(array)). ...
New in JavaScript - Archive of obsolete content
pped in Netscape Navigator 6.0 and Firefox 1.0. Release on November 14, 2000. Standardization work to be compliant with ECMA-262 3rd Edition. JavaScript 1.6 Version shipped in Firefox 1.5. Released in November 2005. Includes ECMAScript for XML (E4X), new Array methods plus String and Array generics. JavaScript 1.7 Version shipped in Firefox 2. Released in October 2006. Includes generators,
iterators, array comprehensions, let expressions, and destructuring assignment. JavaScript 1.8 Version shipped in Firefox 3. Released in June 2008. Includes expression closures, generator expressions and Array.reduce() JavaScript 1.8.1 Version shipped in Firefox 3.5. Released on June 30, 2009. Includes the TraceMonkey JIT and supports native JSON. JavaScript 1.8.2 Version shipped in Firefox 3.6. R...
Reflect.enumerate() - Archive of obsolete content
The static Reflect.enumerate() method used to return an
iterator with the enumerable own and inherited properties of the target object, but has been removed in ECMAScript 2016 and is deprecated in browsers. Syntax Reflect.enumerate(target) Parameters target The target object on which to get the property. Return value An
iterator with the enumerable own and inherited properties of the target object. Exceptions A TypeError, if target is not an Object. Description The Reflect.enumerate method returns an
iterator with the enumerable own and inherited properties of the target object. Examples Using Reflect.enumerate() var obj = { x: 1, y: 2 }; for (var name of Reflect.enumerate(obj)) { console.log(name); } // logs "x" and "y" Specifications Not part of any standard. ...
Archived JavaScript Reference - Archive of obsolete content
ct.prototype.watch()The watch() method watches for a property to be assigned a value and runs a function when that occurs.Object.unobserve()The Object.unobserve() method was used to remove observers set by Object.observe(), but has been deprecated and removed from Browsers. You can use the more general Proxy object instead.Reflect.enumerate()The static Reflect.enumerate() method used to return an
iterator with the enumerable own and inherited properties of the target object, but has been removed in ECMAScript 2016 and is deprecated in browsers.String.prototype.quote()The non-standard quote() method returns a copy of the string, replacing various special characters in the string with their escape sequences and wrapping the result in double-quotes ("). ...
Symbol - MDN Web Docs Glossary: Definitions of Web-related terms
rt(Sym.toString()) // Symbol(Sym), now it works Or you can use the symbol.description property to get its description: let _Sym = Symbol("Sym"); alert(_Sym.description); // Sym Well-known symbols The Symbol class has constants for so-called well-known symbols. These symbols let you configure how JS treats an object, by using them as property keys. Examples of well-known symbols are: Symbol.
iterator for array-like objects, or Symbol.search for string objects. They are listed in the specification in the Well-known symbols table: Symbol.hasInstance Symbol.isConcatSpreadable Symbol.
iterator Symbol.toPrimitive ...and so on. Global symbol registry There is a global symbol registry holding all available symbols. The methods that access the registry are Symbol.for() and Symbol.keyFor(); ...
OS.File.Info
Boolean MacOS X macBirthDate A Date representing the time at which the file was created. May not be exact on all file systems. (As of Firefox 38 this attribute is not found, see screen shots below, Bugzilla :: Bug 1156060) Screenshot of Info object in Variable Viewer MacOSX 10.10.1 Ubuntu 14.04.1 Windows 8.1 See Also OS.File.Directory
Iterator.Entry ...
NSS_3.12_release_notes.html
_ANON_WITH_CAMELLIA_128_CBC_SHA TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA TLS_DH_ANON_WITH_CAMELLIA_256_CBC_SHA TLS_ECDH_anon_WITH_NULL_SHA TLS_ECDH_anon_WITH_RC4_128_SHA TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA TLS_ECDH_anon_WITH_AES_128_CBC_SHA TLS_ECDH_anon_WITH_AES_256_CBC_SHA Bugs Fixed The following bugs have been fixed in NSS 3.12. Bug 354403: nssList_Create
Iterator returns pointer to a freed memory if the function fails to allocate a lock Bug 399236: pkix wrapper must print debug output into stderr Bug 399300: PKIX error results not freed after use. Bug 414985: Crash in pkix_pl_OcspRequest_Destroy Bug 421870: Strsclnt crashed in PKIX tests. Bug 429388: vfychain.main leaks memory Bug 396044: Warning: usage of uninitialized variable in ckfw/object.c(174) Bug ...
JSAPI User Guide
cipals, JS_EvaluateUCScriptForPrincipals Compile and execute a script with security information. Implement access check callback functions (see JSClass.checkAccess and JS_SetCheckObjectAccessCallback). These will be called from JS_CheckAccess and sometimes from within the JavaScript engine. An access check callback function can use jsdbgapi.h functions such as JS_Frame
Iterator and JS_StackFramePrincipals to obtain the principals of the code that is trying to perform the checked operation. Then it determines whether to allow the operation to proceed. Tracing and Profiling There are features provided by the JSAPI that make it easier to implement JavaScript tracers and profilers. Function tracing If you configure with --enable-trace-jscalls, you can use JS_SetFunct...
JSCheckAccessOp
parameter. On success, the callback must set *vp to the stored value of the property. Description Check whether obj[id] may be accessed per mode, returning JS_FALSE on error/exception, JS_TRUE on success with obj[id]'s stored value in *vp. As for JSPropertyOp, id is either a string or an int jsval. JSCheckAccessOp implementations generally work by using JSDBGAPI functions such as JS_Frame
Iterator and JS_StackFramePrincipals to obtain the principals of the code attempting the checked operation, then examining those principals and comparing them with the system's security policy. The nature of principals and the security policy are entirely up to the application. If a class leaves the checkAccess field NULL, a runtime-wide object access callback is called instead; see JS_SetCheckObjectAcce...
JSFastNative
ints to a JSFastNative, use JS_FN. When a JSFastNative is called, no JSStackFrame is generated. This is what makes a fast native fast. However, it causes the function not to appear on the stack in JavaScript debuggers. It also means that applications that use SpiderMonkey's security features, particularly those that implement JSCheckAccessOp or JSCheckAccessIdOp in terms of APIs such as JS_Frame
Iterator and JS_StackFramePrincipals, must take extra care, as the native function's principals will be missing from the stack. See Also JSNative ...
JSNative
terminates the script with an uncatchable error. This has limited use cases; it's used to implement Firefox's "slow script" dialog, for example.) When a JSNative is called, no JSStackFrame is generated. This causes the function not to appear on the stack in JavaScript debuggers. It also means that applications that implement JSCheckAccessOp or JSCheckAccessIdOp in terms of APIs such as JS_Frame
Iterator and JS_StackFramePrincipals, must take extra care, as the native function's principals will be missing from the stack. See Also MXR ID Search for JSNative JS::CallArgs JS_ReportError JS_ReportOutOfMemory JS_SetPendingException ...
JSProtoKey
RangeError MXR Search for JSProto_RangeError JSProto_ReferenceError ReferenceError MXR Search for JSProto_ReferenceError JSProto_SyntaxError SyntaxError MXR Search for JSProto_SyntaxError JSProto_TypeError TypeError MXR Search for JSProto_TypeError JSProto_URIError URIError MXR Search for JSProto_URIError JSProto_
Iterator Iterator MXR Search for JSProto_
Iterator JSProto_StopIteration StopIteration MXR Search for JSProto_StopIteration JSProto_ArrayBuffer ArrayBuffer MXR Search for JSProto_ArrayBuffer JSProto_Int8Array Int8Array MXR Search for JSProto_Int8Array JSProto_Uint8Array Uint8Array MXR Search for JSProto_Uint8Array JSProto_...
JS_FS
Functions or JS_InitClass. JS_FN (whose name pays homage to the old JSNative/JSFastNative split) simply adds the flag JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of JSJitInfos. JS_SELF_HOSTED_FN declares a self-hosted function. Finally JS_FNSPEC has slots for all the fields. The _SYM variants allow defining a function with a symbol key rather than a string key. For example, use JS_SYM_FN(
iterator, ...) to define an @@
iterator method. (In builds without ES6 symbols, it defines a method with the string id "@@
iterator".) See an example in the JSAPI User Guide. See Also MXR ID Search for JS_FS MXR ID Search for JS_FN MXR ID Search for JS_SYM_FN MXR ID Search for JS_FNINFO MXR ID Search for JS_SELF_HOSTED_FN MXR ID Search for JS_SELF_HOSTED_SYM_FN MXR ID Search for JS_SYM_FNSPEC MXR I...
JS_InitStandardClasses
These global objects, functions, constructors, and constants are created as properties of obj. As a side effect, JS_InitStandardClasses establishes obj as the global object for cx, if one is not already established. This means that scripts executed in cx will see the properties of obj as global variables. See JS_SetGlobalObject for details. obj must ...
JS_NewContext
The application must call JS_DestroyContext when it is done using the context. Before a JSRuntime may be destroyed, all the JSContexts associated with it must be destroyed. The new JSContext initially has no global object. The new JSContext is associated with the calling thread. No other thread may use it or destroy it. See Also MXR ID Search for JS_NewContext JS_DestroyContext JS_Context
Iterator JS_SetContextCallback ...
JS_NextProperty
Obsolete since JSAPI 36This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. Get the next property id from an
iterator object produced by JS_NewProperty
Iterator. Syntax bool JS_NextProperty(JSContext *cx, JS::HandleObject iterobj, JS::MutableHandleId idp); Name Type Description cx JSContext * The JS context in which to enumerate properties. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. iterobj JS::HandleObject The opaque
iterator object returned by a previous call to JS_NewProperty
Iterator. idp JS::MutableHandleId Out parameter. On success, *idp receives the name or index of the next ...
JS_ThrowStopIteration
ration exception. Syntax bool JS_ThrowStopIteration(JSContext *cx); Name Type Description cx JSContext * The context in which to throw the StopIteration object. Description JS_ThrowStopIteration throws the appropriate StopIteration object for the function currently executing in cx. In for...in and for each...in loops, the JavaScript engine can create an
iterator object and call its .next method repeatedly, as described in New in JavaScript 1.7:
Iterators. The .next method may throw StopIteration when there are no more values left to iterate. The engine automatically catches the exception and exits the loop. JSClass.enumerate offers a simpler way to customize object iteration. See Also MXR ID Search for JS_ThrowStopIteration JS_IsStopIteration bug ...
SpiderMonkey 38
JSAPI functions that used jschar now use char16_t directly. Embedder code should use char16_t, too. (See bug 1063962.) JS_PreventExtensions...
SpiderMonkey 45
features JavaScript 45 includes significant updates to its language features, yo. New C++ APIs JSAPI is a C++ exclusive API. Please note that SpiderMonkey reserves the JS:: namespace for itself for public exports and the js:: namespace for internal use. ...
Shell global objects
ump'], [filename]) Dump reachable and unreachable objects to the named file, or to stdout. If collectNurseryBeforeDump is specified, a minor GC is performed first, otherwise objects in the nursery are ignored. terminate() Terminate JavaScript execution, as if we had run out of memory or been terminated by the slow script dialog. readSPSProfilingStack() Reads the jit stack using ProfilingFrame
Iterator. enableOsiPointRegisterChecks() Emit extra code to verify live regs at the start of a VM call are not modified before its OsiPoint. displayName(fn) Gets the display name for a function, which can possibly be a guessed or inferred name based on where the function was defined. This can be different from the name property on the function. isAsmJSCompilationAvailable Returns whether asm.js comp...
XPCOM hashtable guide
I. There are three key methods, Get, Put, and Remove, which retrieve entries from the hashtable, write entries into the hashtable, and remove entries from the hashtable respectively. The hashtables that hold references to pointers (nsRefPtrHashtable and nsInterfaceHashtable) also have GetWeak methods that return non-AddRefed pointers. All of these hashtable classes can be iterated over via the
Iterator class and cleared via the Clear method. ...
Detailed XPCOM hashtable guide
o declares functions that manipulate the key. In most cases, the functions of this entry class can be entirely inline. For examples of entry classes, see the declarations at xpcom/glue/nsHashKeys.h. The template parameter is the entry class. You must use the Init() function to initalize the table properly. At this point, use the functions PutEntry/GetEntry/RemoveEntry to alter the hashtable. The
Iterator class will do iteration, but beware that the iteration will occur in a seemingly-random order (no sorting). nsTHashtables can be allocated on the stack, as class members, or on the heap. Entry pointers can and do change when items are added to or removed from the hashtable. Do not keep long-lasting pointers to entries. because of this, nsTHashtable is not inherently thread-safe. If you use a...
XPCOM Interface Reference
tionnsIDOMXPathExpressionnsIDOMXPathResultnsIDOMXULControlElementnsIDOMXULElementnsIDOMXULLabeledControlElementnsIDOMXULSelectControlElementnsIDOMXULSelectControlItemElementnsIDataSignatureVerifiernsIDebugnsIDebug2nsIDeviceMotionnsIDeviceMotionDatansIDeviceMotionListenernsIDialogCreatornsIDialogParamBlocknsIDictionarynsIDirIndexnsIDirIndexListenernsIDirIndexParsernsIDirectoryEnumeratornsIDirectory
IteratornsIDirectoryServicensIDirectoryServiceProvidernsIDirectoryServiceProvider2nsIDiskCacheStreamInternalnsIDispatchSupportnsIDocShellnsIDocumentLoadernsIDownloadnsIDownloadHistorynsIDownloadManagernsIDownloadManagerUInsIDownloadObservernsIDownloadProgressListenernsIDownloadernsIDragDropHandlernsIDragServicensIDragSessionnsIDroppedLinkHandlernsIDroppedLinkItemnsIDynamicContainernsIEditornsIEditorBoxObj...
XPCOM Interface Reference by grouping
nsIComponentManager Preferences nsIContentPrefObserver nsIContentPrefService nsIComponentRegistrar Internationalization nsIBidiKeyboard nsILocale IO FileSystem nsIDirectoryEnumerator nsIDirectory
Iterator nsIDirectoryService nsIDirectoryServiceProvider nsIDirectoryServiceProvider2 nsIDirIndex nsIDirIndexListener nsIDirIndexParser nsIFile nsILocalFile Stream nsIAsyncInputStream nsIAsyncOutputStream nsIAsyncStreamCopier nsIBin...
Folders and message lists
l the view so the entire selection is visible (which may not be possible for large selections). gFolderDisplay.clearSelection(): Clears the list of selected messages. Listing Messages in a Folder If you have a message folder, and would like to list all the messages in that folder, you can use the .messages attribute, which returns an nsISimpleEnumerator. It's used like this: // Import the fix
Iterator() function. Components.utils.import("resource:///modules/
iteratorUtils.jsm"); for (let msgHdr in fix
Iterator(myFolder.messages, Components.interfaces.nsIMsgDBHdr)) { // Do something with msgHdr... } ...
AudioListener.dopplerFactor - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.forwardX - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.forwardY - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.forwardZ - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.positionX - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.positionY - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.positionZ - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.setOrientation() - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.setPosition() - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.speedOfSound - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.upX - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.upY - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener.upZ - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
AudioListener - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
BaseAudioContext.createPanner() - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
CSSUnparsedValue - Web APIs
.entries() Returns an array of a given object's own enumerable property [key, value] pairs in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well). CSSUnparsedValue.forEach() Executes a provided function once for each element of the CSSUnparsedValue object. CSSUnparsedValue.keys() Returns a new Array
Iterator object that contains the keys for each index in the CSSUnparsedValue object. CSSUnparsedValue.values() Returns a new Array
Iterator object that contains the values for each index in the CSSUnparsedValue object. Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSUnparsedValue' in that specification. Working Draft Initial definit...
CSS Typed Object Model API - Web APIs
returning an array of a given object's own enumerable property [key, value] pairs in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well). CSSUnparsedValue.forEach() Method executing a provided function once for each element of the CSSUnparsedValue. CSSUnparsedValue.keys() Method returning a new Array
Iterator object that contains the keys for each index in the array. CSSKeywordValue Serialization The CSSKeywordValue interface of the the CSS Typed Object Model API creates an object to represent CSS keywords and other identifiers. CSSKeywordValue.CSSKeywordValue() constructor Constructor creates a new CSSKeywordValue.CSSKeywordValue() object which represents CSS keywords and other identifiers. C...
Document.createTreeWalker() - Web APIs
n flag indicating if when discarding an EntityReference its whole sub-tree must be discarded at the same time. Return value A new TreeWalker object. Example The following example goes through all nodes in the body, reduces the set of nodes to elements, simply passes through as acceptable each node (it could reduce the set in the acceptNode() method instead), and then makes use of tree walker
iterator that is created to advance through the nodes (now all elements) and push them into an array. var treeWalker = document.createTreeWalker( document.body, NodeFilter.SHOW_ELEMENT, { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } }, false ); var nodeList = []; var currentNode = treeWalker.currentNode; while(currentNode) { nodeList.push(currentNode); currentNode = treeW...
Document - Web APIs
. Document.createDocumentFragment() Creates a new document fragment. Document.createElement() Creates a new element with the given tag name. Document.createElementNS() Creates a new element with the given tag name and namespace URI. Document.createEntityReference() Creates a new entity reference object and returns it. Document.createEvent() Creates an event object. Document.createNode
Iterator() Creates a Node
Iterator object. Document.createProcessingInstruction() Creates a new ProcessingInstruction object. Document.createRange() Creates a Range object. Document.createTextNode() Creates a text node. Document.createTouch() Creates a Touch object. Document.createTouchList() Creates a TouchList object. Document.createTreeWalker() Creates a TreeWalker object. Document.enabl...
How whitespace is handled by HTML, CSS, and in the DOM - Web APIs
lementing the |CharacterData| interface (i.e., * a |Text|, |Comment|, or |CDATASection| node * @return True if all of the text content of |nod| is whitespace, * otherwise false. */ function is_all_ws( nod ) { // Use ECMA-262 Edition 3 String and RegExp features return !(/[^\t\n\r ]/.test(nod.textContent)); } /** * Determine if a node should be ignored by the
iterator functions. * * @param nod An object implementing the DOM1 |Node| interface. * @return true if the node is: * 1) A |Text| node that is all whitespace * 2) A |Comment| node * and otherwise false. */ function is_ignorable( nod ) { return ( nod.nodeType == 8) || // A comment node ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text nod...
Document Object Model (DOM) - Web APIs
documents, see our article Introduction to the DOM. DOM interfaces Attr CDATASection CharacterData ChildNode Comment CustomEvent Document DocumentFragment DocumentType DOMError DOMException DOMImplementation DOMString DOMTimeStamp DOMStringList DOMTokenList Element Event EventTarget HTMLCollection MutationObserver MutationRecord NamedNodeMap Node NodeFilter Node
Iterator NodeList NonDocumentTypeChildNode ParentNode ProcessingInstruction Selection Range Text TextDecoder TextEncoder TimeRanges TreeWalker URL Window Worker XMLDocument Obsolete DOM interfaces The Document Object Model has been highly simplified. To achieve this, the following interfaces present in the different DOM level 3 or earlier specifications have been removed. It is ...
FormData.entries() - Web APIs
The FormData.entries() method returns an
iterator allowing to go through all key/value pairs contained in this object. The key of each pair is a USVString object; the value either a USVString, or a Blob. Note: This method is available in Web Workers. Syntax formData.entries(); Return value Returns an
iterator. Example // Create a test FormData object var formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // Display the key/value pairs for(var pair of formData.entries()) { console.log(pair[0]+ ', '+ pair[1]); } The result is: key1, value1 key2, value2 Specifications Specification Status Comment XMLHttpRequestThe definition of 'entries() (as
iterator<>)' in that specification. Living Standard Initial defin...
FormData.keys() - Web APIs
The FormData.keys() method returns an
iterator allowing to go through all keys contained in this object. The keys are USVString objects. Note: This method is available in Web Workers. Syntax formData.keys(); Return value Returns an
iterator. Example // Create a test FormData object var formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // Display the keys for (var key of formData.keys()) { console.log(key); } The result is: key1 key2 Specifications Specification Status Comment XMLHttpRequestThe definition of 'keys() (as
iterator<>)' in that specification. Living Standard Initial definition ...
FormData.values() - Web APIs
The FormData.values() method returns an
iterator allowing to go through all values contained in this object. The values are USVString or Blob objects. Note: This method is available in Web Workers. Syntax formData.values(); Return value Returns an
iterator. Example // Create a test FormData object var formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // Display the values for (var value of formData.values()) { console.log(value); } The result is: value1 value2 Specifications Specification Status Comment XMLHttpRequestThe definition of 'values() (as
iterator<>)' in that specification. Living Standard Initial definition ...
Headers.entries() - Web APIs
The Headers.entries() method returns an
iterator allowing to go through all key/value pairs contained in this object. The both the key and value of each pairs are ByteString objects. Note: This method is available in Web Workers. Syntax headers.entries(); Return value Returns an
iterator. Example // Create a test Headers object var myHeaders = new Headers(); myHeaders.append('Content-Type', 'text/xml'); myHeaders.append('Vary', 'Accept-Language'); // Display the key/value pairs for (var pair of myHeaders.entries()) { console.log(pair[0]+ ': '+ pair[1]); } The result is: content-type: text/xml vary: Accept-Language ...
Headers.keys() - Web APIs
The Headers.keys() method returns an
iterator allowing to go through all keys contained in this object. The keys are ByteString objects. Note: This method is available in Web Workers. Syntax headers.keys(); Return value Returns an
iterator. Example // Create a test Headers object var myHeaders = new Headers(); myHeaders.append('Content-Type', 'text/xml'); myHeaders.append('Vary', 'Accept-Language'); // Display the keys for(var key of myHeaders.keys()) { console.log(key); } The result is: content-type vary ...
Headers.values() - Web APIs
The Headers.values() method returns an
iterator allowing to go through all values contained in this object. The values are ByteString objects. Note: This method is available in Web Workers. Syntax headers.values(); Return value Returns an
iterator. Example // Create a test Headers object var myHeaders = new Headers(); myHeaders.append('Content-Type', 'text/xml'); myHeaders.append('Vary', 'Accept-Language'); // Display the values for (var value of myHeaders.values()) { console.log(value); } The result is: text/xml Accept-Language ...
KeyboardLayoutMap - Web APIs
the UI Events KeyboardEvent code Values specification. Properties KeyboardLayoutMap.entries Read only Returns an array of a given object's own enumerable property [key, value] pairs, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well). KeyboardLayoutMap.keys Read only Returns a new Array
Iterator object that contains the keys for each index in the array. KeyboardLayoutMap.size Read only Returns the number of elements in the KeyboardLayoutMap object. KeyboardLayoutMap.values Read only Returns a new Array
Iterator object that contains the values for each index in the KeyboardLayoutMap object. Methods KeyboardLayoutMap.forEach() Read only Executes a provided function once ...
MediaKeyStatusMap.entries() - Web APIs
Syntax // TBD Parameters None. Returns Exceptions Specifications Specification Status Comment Encrypted Media Extensions Recommendation Initial definition. Browser Compatibility The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. ...
MediaKeyStatusMap.keys() - Web APIs
Syntax var
iterator = mediaKeyStatusMap.keys() Parameters None. Returns A new
iterator. Specifications Specification Status Comment Encrypted Media Extensions Recommendation Initial definition. Browser Compatibility The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. ...
MediaKeyStatusMap.values() - Web APIs
Syntax var
iterator = mediaKeyStatusMap.values() Parameters None. Returns A new
iterator. Specifications Specification Status Comment Encrypted Media Extensions Recommendation Initial definition. Browser Compatibility The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. ...
NodeList.entries() - Web APIs
The NodeList.entries() method returns an
iterator allowing to go through all key/value pairs contained in this object. The values are Node objects. Syntax list.entries(); Return value Returns an
iterator. Example var node = document.createElement("div"); var kid1 = document.createElement("p"); var kid2 = document.createTextNode("hey"); var kid3 = document.createElement("span"); node.appendChild(kid1); node.appendChild(kid2); node.appendChild(kid3); var list = node.childNodes; // Using for..of for(var entry of list.entries()) { console.log(entry); } results in: Array [ 0, <p> ] Array [ 1, #text "hey" ] Array [ 2, <span> ] ...
NodeList.keys() - Web APIs
The NodeList.keys() method returns an
iterator allowing to go through all keys contained in this object. The keys are unsigned integer. Syntax nodeList.keys(); Return value Returns an
iterator. Example var node = document.createElement("div"); var kid1 = document.createElement("p"); var kid2 = document.createTextNode("hey"); var kid3 = document.createElement("span"); node.appendChild(kid1); node.appendChild(kid2); node.appendChild(kid3); var list = node.childNodes; // Using for..of for(var key of list.keys()) { console.log(key); } The result is: 0 1 2 ...
NodeList.length - Web APIs
The NodeList.length property returns the number of items in a NodeList. Syntax numItems = nodeList.length numItems is an integer value representing the number of items in a NodeList. Example The length property is often useful in DOM programming. It's often used to test the length of a list, to see if it exists at all. It's also commonly used as the
iterator in a for loop, as in this example. // All the paragraphs in the document var items = document.getElementsByTagName("p"); // For each item in the list, // append the entire element as a string of HTML var gross = ""; for (var i = 0; i < items.length; i++) { gross += items[i].innerHTML; } // gross is now all the HTML for the paragraphs Specifications Specification Status Comment DOMThe definition of ...
NodeList.values() - Web APIs
The NodeList.values() method returns an
iterator allowing to go through all values contained in this object. The values are Node objects. Syntax nodeList.values(); Return value Returns an
iterator. Example var node = document.createElement("div"); var kid1 = document.createElement("p"); var kid2 = document.createTextNode("hey"); var kid3 = document.createElement("span"); node.appendChild(kid1); node.appendChild(kid2); node.appendChild(kid3); var list = node.childNodes; // Using for..of for(var value of list.values()) { console.log(value); } The result is: <p> #text "hey" <span> ...
PannerNode.distanceModel - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
PannerNode.maxDistance - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
PannerNode.panningModel - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
PannerNode.setOrientation() - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
PannerNode.setPosition() - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
PannerNode.setVelocity() - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
PannerNode - Web APIs
udioCtx.currentTime); } else { listener.setOrientation(0,0,-1,0,1,0); } var source; var play = document.querySelector('.play'); var stop = document.querySelector('.stop'); var boomBox = document.querySelector('.boom-box'); var listenerData = document.querySelector('.listener-data'); var pannerData = document.querySelector('.panner-data'); leftBound = (-xPos) + 50; rightBound = xPos - 50; x
Iterator = WIDTH/150; // listener will always be in the same place for this demo if(listener.positionX) { listener.positionX.setValueAtTime(xPos, audioCtx.currentTime); listener.positionY.setValueAtTime(yPos, audioCtx.currentTime); listener.positionZ.setValueAtTime(300, audioCtx.currentTime); } else { listener.setPosition(xPos,yPos,300); } listenerData.innerHTML = 'Listener data: X ' + xPos + '...
StylePropertyMapReadOnly - Web APIs
ylePropertyMapReadOnly. StylePropertyMapReadOnly.get() Returns the value of the specified property. StylePropertyMapReadOnly.getAll() Returns an array of CSSStyleValue objects containing the values for the provided property. StylePropertyMapReadOnly.has() Indicates whether the specified property is in the StylePropertyMapReadOnly object. StylePropertyMapReadOnly.keys() Returns a new Array
Iterator containing the keys for each item in StylePropertyMapReadOnly. StylePropertyMapReadOnly.values() Returns a new Array
Iterator containing the values for each index in the StylePropertyMapReadOnly object. Examples We have to have an element to observe: <p> This is a paragraph with some text. We can add some CSS, or not. The style map will include all the default and inherted CSS propert...
URLSearchParams.entries() - Web APIs
The entries() method of the URLSearchParams interface returns an
iterator allowing iteration through all key/value pairs contained in this object. The key and value of each pair are USVString objects. Note: This feature is available in Web Workers. Syntax searchParams.entries(); Parameters None. Return value Returns an
iterator. Examples // Create a test URLSearchParams object var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Display the key/value pairs for(var pair of searchParams.entries()) { console.log(pair[0]+ ', '+ pair[1]); } The result is: key1, value1 key2, value2 Specifications Specification Status Comment URLThe definition of 'entries() (see "iterable")' in that specification. Living Standard Initial definition. ...
URLSearchParams.keys() - Web APIs
The keys() method of the URLSearchParams interface returns an
iterator allowing iteration through all keys contained in this object. The keys are USVString objects. Note: This method is available in Web Workers. Syntax searchParams.keys(); Parameters None. Return value Returns an
iterator. Examples // Create a test URLSearchParams object var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Display the keys for(var key of searchParams.keys()) { console.log(key); } The result is: key1 key2 Specifications Specification Status Comment URLThe definition of 'keys() (see "iterable")' in that specification. Living Standard Initial definition. ...
URLSearchParams.values() - Web APIs
The values() method of the URLsearchParams interface returns an
iterator allowing iteration through all values contained in this object. The values are USVString objects. Note: This feature is available in Web Workers. Syntax searchParams.values(); Parameters None. Return value Returns an
iterator. Examples // Create a test URLSearchParams object var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Display the values for(var value of searchParams.values()) { console.log(value); } The result is: value1 value2 Specifications Specification Status Comment URLThe definition of 'values() (see "iterable")' in that specification. Living Standard Initial definition. ...
XPathResult.iterateNext() - Web APIs
The iterateNext() method of the XPathResult interface iterates over a node set result and returns the next node from it or null if there are no more nodes. Syntax var node = result.iterateNext(); Return value The next Node within the node set of the XPathResult. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_
ITERATOR_TYPE or ORDERED_NODE_
ITERATOR_TYPE, an XPathException of type TYPE_ERR is thrown. INVALID_STATE_ERR If the document is mutated since the result was returned, an XPathException of type INVALID_STATE_ERR is thrown. Example The following example shows the use of the iterateNext() method. HTML <div>XPath example</div> <div>Tag names of the matched nodes: <output></output></div> JavaScript var xpath = "//div"; var result = document.evaluate(xpath...
XPathResult.snapshotItem() - Web APIs
Syntax var node = result.snapshotItem(i); Return value The Node at the given index within the node set of the XPathResult. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. ...
XRInputSourceArray.forEach() - Web APIs
, taken from its gamepad property, as an input For other devices, we look for tracked-pointer devices in the player's main hand, dispatching those to a handleMainHandInput() method. Specifications Specification Status Comment WebXR Device APIThe definition of 'XRInputSourceArray' in that specification.1 Working Draft XRInputSourceArray interface [1] See
Iterator-like methods in Information contained in a WebIDL file for information on how an iterable declaration in an interface definition causes entries(), forEach(), keys(), and values() methods to be exposed from objects that implement the interface. ...
Web APIs
peArray MouseEvent MouseScrollEvent MouseWheelEvent MutationEvent MutationObserver MutationObserverInit MutationRecord N NDEFMessage NDEFReader NDEFReadingEvent NDEFRecord NDEFWriter NameList NamedNodeMap NavigationPreloadManager Navigator NavigatorConcurrentHardware NavigatorID NavigatorLanguage NavigatorOnLine NavigatorPlugins NavigatorStorage NetworkInformation Node NodeFilter Node
Iterator NodeList NonDocumentTypeChildNode Notation Notification NotificationAction NotificationEvent NotifyAudioAvailableEvent O OES_element_index_uint OES_fbo_render_mipmap OES_standard_derivatives OES_texture_float OES_texture_float_linear OES_texture_half_float OES_texture_half_float_linear OES_vertex_array_object OVR_multiview2 OfflineAudioCompletionEvent OfflineAudioContext OffscreenCanvas ...
Regular expressions - JavaScript
pressions Method Description exec() Executes a search for a match in a string. It returns an array of information or null on a mismatch. test() Tests for a match in a string. It returns true or false. match() Returns an array containing all of the matches, including capturing groups, or null if no match is found. matchAll() Returns an
iterator containing all of the matches, including capturing groups. search() Tests for a match in a string. It returns the index of the match, or -1 if the search fails. replace() Executes a search for a match in a string, and replaces the matched substring with a replacement substring. replaceAll() Executes a search for all matches in a string, and replaces the matched...
JavaScript Guide - JavaScript
ndexed collections Arrays Typed arrays Keyed collections Map WeakMap Set WeakSet Working with objects Objects and properties Creating objects Defining methods Getter and setter Details of the object model Prototype-based OOP Creating object hierarchies Inheritance Promises Guarantees Chaining Error propagation Composition Timing
Iterators and generators
Iterators Iterables Generators Meta programming Proxy Handlers and traps Revocable Proxy Reflect JavaScript modules Exporting Importing Default exports Renaming features Aggregating modules Dynamic module loading Next >> ...
Deprecated and obsolete features - JavaScript
because they leak the function caller. Instead of the arguments property, you should use the arguments object inside function closures. Legacy generator Legacy generator function statement and Legacy generator function expression are deprecated. Use function* statement and function* expression instead. JS1.7/JS1.8 Array comprehension and JS1.7/JS1.8 Generator comprehension are deprecated.
Iterator StopIteration is deprecated.
Iterator is deprecated. Object methods watch and unwatch are deprecated. Use Proxy instead. __
iterator__ is deprecated. __noSuchMethod__ is deprecated. Use Proxy instead. Date methods getYear and setYear are affected by the Year-2000-Problem and have been subsumed by getFullYear and setFullYear. You should use toISOString instead of the deprecated toG...
Warning: JavaScript 1.6's for-each-in loops are deprecated - JavaScript
if (array) { for (var x of array) { console.log(x); } } } func([10, 20]); // 10 // 20 func(null); // prints nothing func(undefined); // prints nothing Iterating over an object's key-value pair Deprecated syntax There's a deprecated idiom to iterate over the specified object's key-value pairs using for each...in and the deprecated
Iterator object. var object = { a: 10, b: 20 }; for each (var [key, value] in
Iterator(object)) { console.log(key, value); // "a", 10 // "b", 20 } Alternative standard syntax You can now use the standard for...in loop to iterate over specified object keys, and get each value inside the loop: var object = { a: 10, b: 20 }; for (var key in object) { var value = object...
The arguments object - JavaScript
guments); // 'object' The type of individual arguments can be determined by indexing arguments: console.log(typeof arguments[0]); // returns the type of the first argument Properties arguments.callee Reference to the currently executing function that the arguments belong to. Forbidden in strict mode. arguments.length The number of arguments that were passed to the function. arguments[@@
iterator] Returns a new Array
iterator object that contains the values for each index in arguments. Examples Defining a function that concatenates several strings This example defines a function that concatenates several strings. The function's only formal argument is a string containing the characters that separate the items to concatenate. function myConcat(separator) { let args = Array.prototyp...
Generator.prototype.next() - JavaScript
next method to send a value to the generator. Syntax gen.next(value) Parameters value The value to send to the generator. The value will be assigned as a result of a yield expression. For example, in variable = yield expression, the value passed to the .next() function will be assigned to variable. Return value An Object with two properties: done (boolean) Has the value true if the
iterator is past the end of the iterated sequence. In this case value optionally specifies the return value of the
iterator. Has the value false if the
iterator was able to produce the next value in the sequence. This is equivalent of not specifying the done property altogether. value Any JavaScript value returned by the
iterator. Can be omitted when done is true. Examples Using next() The followin...
Generator.prototype.throw() - JavaScript
The throw() method resumes the execution of a generator by throwing an error into it and returns an object with two properties done and value. Syntax gen.throw(exception) Parameters exception The exception to throw. For debugging purposes, it is useful to make it an instanceof Error. Return value An Object with two properties: done (boolean) Has the value true if the
iterator is past the end of the iterated sequence. In this case value optionally specifies the return value of the
iterator. Has the value false if the
iterator was able to produce the next value in the sequence. This is equivalent of not specifying the done property altogether. value Any JavaScript value returned by the
iterator. Can be omitted when done is true. Examples Using throw() The following ex...
GeneratorFunction - JavaScript
ith code for a generator function expression. Invoking the GeneratorFunction constructor as a function (without using the new operator) has the same effect as invoking it as a constructor. Examples Creating a generator function from a GeneratorFunction() constructor var GeneratorFunction = Object.getPrototypeOf(function*(){}).constructor var g = new GeneratorFunction('a', 'yield a * 2'); var
iterator = g(10); console.log(
iterator.next().value); // 20 Specifications Specification ECMAScript (ECMA-262)The definition of 'GeneratorFunction' in that specification. ...
Object.fromEntries() - JavaScript
rable An iterable such as Array or Map or other objects implementing the iterable protocol. Return value A new object whose properties are given by the entries of the iterable. Description The Object.fromEntries() method takes a list of key-value pairs and returns a new object whose properties are given by those entries. The iterable argument is expected to be an object that implements an @@
iterator method, that returns an
iterator object, that produces a two element array-like object, whose first element is a value that will be used as a property key, and whose second element is the value to associate with that property key. Object.fromEntries() performs the reverse of Object.entries(). Examples Converting a Map to an Object With Object.fromEntries, you can convert from Map to Object: ...
Set.prototype.entries() - JavaScript
The entries() method returns a new
Iterator object that contains an array of [value, value] for each element in the Set object, in insertion order. For Set objects there is no key like in Map objects. However, to keep the API similar to the Map object, each entry has the same value for its key and value here, so that an array [value, value] is returned. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax mySet.entries() Return value A new
Iterator object that contains an array of [value, value] for each element in the given Set, in insertion order. Examples Using entries() var mySet = new Set(); mySet.add('foob...
Set.prototype.values() - JavaScript
The values() method returns a new
Iterator object that contains the values for each element in the Set object in insertion order. The keys() method is an alias for this method (for similarity with Map objects); it behaves exactly the same and returns values of Set elements. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax mySet.values(); Return value A new
Iterator object containing the values for each element in the given Set, in insertion order. Examples Using values() var mySet = new Set(); mySet.add('foo'); mySet.add('bar'); mySet.add('baz'); var setIter = mySet.values(); console.log(setIter.next().v...
String length - JavaScript
r an empty string, length is 0. The static property String.length is unrelated to the length of strings, it's the arity of the String function (loosely, the number of formal parameters it has), which is 1. ...
Symbol.prototype.description - JavaScript
cription property can be used to read that description. It is different to Symbol.prototype.toString() as it does not contain the enclosing "Symbol()" string. See the examples. Examples Using description Symbol('desc').toString(); // "Symbol(desc)" Symbol('desc').description; // "desc" Symbol('').description; // "" Symbol().description; // undefined // well-known symbols Symbol.
iterator.toString(); // "Symbol(Symbol.
iterator)" Symbol.
iterator.description; // "Symbol.
iterator" // global symbols Symbol.for('foo').toString(); // "Symbol(foo)" Symbol.for('foo').description; // "foo" Specifications Specification ECMAScript (ECMA-262)The definition of 'get Symbol.prototype.description' in that specification. ...
Symbol.keyFor() - JavaScript
ng representing the key for the given symbol if one is found on the global registry; otherwise, undefined. Examples Using keyFor var globalSym = Symbol.for('foo'); // create a new global symbol Symbol.keyFor(globalSym); // "foo" var localSym = Symbol(); Symbol.keyFor(localSym); // undefined // well-known symbols are not symbols registered // in the global symbol registry Symbol.keyFor(Symbol.
iterator) // undefined Specifications Specification ECMAScript (ECMA-262)The definition of 'Symbol.keyFor' in that specification. ...
Symbol.matchAll - JavaScript
This function is called by the String.prototype.matchAll() method. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Description This Symbol is used for String.prototype.matchAll() and specifically in RegExp.prototype[@@matchAll](). The following two examples return same result: 'abc'.matchAll(/a/); /a/[Symbol.matchAll]('abc'); This method exists for customizing match behavior within RegExp subclasses. ...
Symbol.prototype.toString() - JavaScript
totype.toString(). For Symbol objects, the toString method returns a string representation of the object. No string concatenation While you can call toString() on Symbols, you cannot use string concatenation with them: Symbol('foo') + 'bar' // TypeError: Can't convert symbol to string Examples Using toString Symbol('desc').toString() // "Symbol(desc)" // well-known symbols Symbol.
iterator.toString() // "Symbol(Symbol.
iterator) // global symbols Symbol.for('foo').toString() // "Symbol(foo)" Specifications Specification ECMAScript (ECMA-262)The definition of 'Symbol.prototype.toString' in that specification. ...
TypedArray.from() - JavaScript
If the thisArg value passed to TypedArray.from() is not a constructor, TypedArray.from() will throw a TypeError, where Array.from() defaults to creating a new Array. TypedArray.from() uses [[Put]] where Array.from() uses [[DefineProperty]]. Hence, when working with Proxy objects, it calls handler.set to create new elements rather than handler.defineProperty(). When the source parameter is an
iterator, the TypedArray.from() first collects all the values from the
iterator, then creates an instance of thisArg using the count, then sets the values on the instance. Array.from() sets each value as it receives them from the
iterator, then sets its length at the end. When Array.from() gets an array-like which isn't an
iterator, it respects holes. TypedArray.from() will ensure the result is dense. ...
TypedArray.prototype.keys() - JavaScript
The keys() method returns a new Array
Iterator object that contains the keys for each index in the array. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax arr.keys() Return value A new Array
Iterator object. Examples Iteration using for...of loop var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArray = arr.keys(); // your browser must support for..of loop // and let-scoped variables in for loops for (let n of eArray) { console.log(n); } Alternative iteration var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArr = arr.keys(); console.log(eArr.next().value); // 0 console.log(eArr.next().value); // ...
TypedArray.prototype.values() - JavaScript
The values() method returns a new Array
Iterator object that contains the values for each index in the array. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax arr.values() Return value A new Array
Iterator object. Examples Iteration using for...of loop var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArray = arr.values(); // your browser must support for..of loop // and let-scoped variables in for loops for (let n of eArray) { console.log(n); } Alternative iteration var arr = new Uint8Array([10, 20, 30, 40, 50]); var eArr = arr.values(); console.log(eArr.next().value); // 10 console.log(eArr.next().
in operator - JavaScript
The following examples show some uses of the in operator. // Arrays let trees = ['redwood', 'bay', 'cedar', 'oak', 'maple'] 0 in trees // returns true 3 in trees // returns true 6 in trees // returns false 'bay' in trees // returns false (you must specify the index number, not the value at that index) 'length' in trees // returns true (length is an Array property) Symbol.
iterator in trees // returns true (arrays are iterable, works only in ES2015+) // Predefined objects 'PI' in Math // returns true // Custom objects let mycar = {make: 'Honda', model: 'Accord', year: 1998} 'make' in mycar // returns true 'model' in mycar // returns true You must specify an object on the right side of the in operator. For example, you can specify a string created with the Stri...
typeof - JavaScript
ng into a string, safer than toString // Booleans typeof true === 'boolean'; typeof false === 'boolean'; typeof Boolean(1) === 'boolean'; // Boolean() will convert values based on if they're truthy or falsy typeof !!(1) === 'boolean'; // two calls of the ! ...