Search completed in 1.21 seconds.
TypedArray - JavaScript
A
TypedArray object describes an array-like view of an underlying binary data buffer. There is no global property named
TypedArray, nor is there a directly visible
TypedArray constructor. Instead, there are a number of different global properties, whose values are typed array constructors for specific element types, listed below. On the following pages you will find common properties and methods that can be used with any typed array containing elements of any type. 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. ...
...ollowing pages you will find common properties and methods that can be used with any typed array containing elements of any type. 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 ECMAScript 2015 defines a
TypedArray constructor that serves as the [[Prototype]] of all
TypedArray constructors. This constructor is not directly exposed: there is no global %
TypedArray% or
TypedArray property. It is only directly accessible through Object.getPrototypeOf(Int8Array) and similar. All
TypedArrays constructors inherit common properties from the %
TypedArray% constructor function. Additionally, all typed array protot...
...ructor that serves as the [[Prototype]] of all
TypedArray constructors. This constructor is not directly exposed: there is no global %
TypedArray% or
TypedArray property. It is only directly accessible through Object.getPrototypeOf(Int8Array) and similar. All
TypedArrays constructors inherit common properties from the %
TypedArray% constructor function. Additionally, all typed array prototypes (
TypedArray.prototype) have %
TypedArray%.prototype as their [[Prototype]]. The %
TypedArray% constructor on its own is not particularly useful. Calling it or using it in a new expression will throw a TypeError, except when used during object creation in JS engines that support subclassing. ...
...And 25 more matches
TypedArray.from() - JavaScript
mapFn Optional Map function to call on every element of the typed array. ...
... mapFn Optional Map function to call on every element of the typed array. ...
...ates a new typed array from an array-like or iterable object. This method is nearly the same as Array.from(). 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
TypedArray.from(source[, mapFn[, thisArg]]) Where
TypedArray is one of: Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array BigInt64Array BigUint64Array Parameters source An array-like or iterable object to convert to a typed array. mapFn Optional Map function to call on every element of the typed array. thisArg Optional Value to use as this when executing mapFn. Return v...
...And 8 more matches
TypedArray.of() - JavaScript
The
TypedArray.of() method creates a new typed array from a variable number of arguments. This method is nearly the same as Array.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. Syntax
TypedArray.of(element0[, element1[, ...[, elementN]]]) where
TypedArray is one of: Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array BigInt64Array BigUint64Array Parameters elementN Elements of which to create the typed array. Return value A new
TypedArray instance. ...
...Hence, when working with Proxy objects, it calls handler.set to create new elements rather than handler.defineProperty. ...
...Hence, when working with Proxy objects, it calls handler.set to create new elements rather than handler.defineProperty. ...
...And 2 more matches
TypedArray.prototype.set() - JavaScript
The set() method stores multiple values in the typed array, reading input values from a specified 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. ...
... The set() method stores multiple values in the typed array, reading input values from a specified 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. ...
... The set() method stores multiple values in the typed array, reading input values from a specified 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. ...
...And 2 more matches
TypedArray.prototype.fill() - 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
typedarray.fill(value[, start = 0[, end = this.length]]) Parameters value Value to fill the typed array with. start Optional. Start index. Defaults to 0. ...
...m a start index to an end index with a static value. This method has the same algorithm as Array.prototype.fill().
TypedArray is one of the typed array types here. 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
typedarray.fill(value[, start = 0[, end = this.length]]) Parameters value Value to fill the typed array with. start Optional. Start index. Defaults to 0. end Optional. End index (not included). Defaults to this.length. Return value The modified array. Description The elements interval to fill is [start, end). The fill method takes up to three arguments value, start and end. The start and end ...
...erval to fill is [start, end). The fill method takes up to three arguments value, start and end. The start and end arguments are optional with default values of 0 and the length of the this object. If start is negative, it is treated as length+start where length is the length of the array. If end is negative, it is treated as length+end. Polyfill Since there is no global object with the name
TypedArray, polyfilling must be done on an "as needed" basis. Use the following "polyfill" along with the Array.prototype.fill() polyfill. // https://tc39.github.io/ecma262/#sec-%
typedarray%.prototype.fill if (!Uint8Array.prototype.fill) { Uint8Array.prototype.fill = Array.prototype.fill; } Examples Using fill new Uint8Array([1, 2, 3]).fill(4); // Uint8Array [4, 4, 4] new Uint8Array([1, 2, 3]...
... ...
TypedArray.name - JavaScript
The name property describes of what data type the array consists. ...
...The name property describes of what data type the array consists. ...
...his 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. Property attributes of
TypedArray.name Writable no Enumerable no Configurable no Description
TypedArray objects differ from each other in the number of bytes per element and in the way the bytes are interpreted. The name property describes of what data type the array consists. The first part can be Int for "integer" or Uint for an "unsigned integer", also Float for "floating point" is used. The second part is a number describing the bit-size of the array. Finally, the object type is Array, with Cla...
... ...
TypedArray.prototype.slice() - 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
typedarray.slice([begin[, end]]) Parameters begin Optional Zero-based index at which to begin extraction. A negative index can be used, indicating an offset from the end of the sequence. ...
...ion of a typed array into a new typed array object. This method has the same algorithm as Array.prototype.slice().
TypedArray is one of the typed array types here. 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
typedarray.slice([begin[, end]]) Parameters begin Optional Zero-based index at which to begin extraction. A negative index can be used, indicating an offset from the end of the sequence. slice(-2) extracts the last two elements in the sequence. If begin is undefined, slice begins from index 0. end Optional Zero-based index before which to end extraction. slice extracts up to but not including end. ...
...n. slice extracts up to but not including end. For example, slice(1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3). A negative index can be used, indicating an offset from the end of the sequence. slice(2,-1) extracts the third element through the second-to-last element in the sequence. If end is omitted, slice extracts through the end of the sequence (
typedarray.length). Return value A new typed array containing the extracted elements. Description The slice method does not alter. It returns a shallow copy of elements from the original typed array. If a new element is added to either typed array, the other typed array is not affected. Polyfill Since there is no global object with the name
TypedArray, polyfilling must be done on an "as needed" basi...
...ethods at all, as you can't make them non-enumerable. Examples Return a portion of an existing typed array const uint8 = new Uint8Array([1,2,3]); uint8.slice(1); // Uint8Array [ 2, 3 ] uint8.slice(2); // Uint8Array [ 3 ] uint8.slice(-2); // Uint8Array [ 2, 3 ] uint8.slice(0,1); // Uint8Array [ 1 ] Specifications Specification ECMAScript (ECMA-262)The definition of '%
TypedArray%.prototype.slice' in that specification. ...
TypedArray.prototype.some() - 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. ...
...asses the test implemented by the provided function. This method has the same algorithm as Array.prototype.some().
TypedArray is one of the typed array types here. 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
typedarray.some(callback[, thisArg]) Parameters callback Function to test for each element, taking three arguments: currentValue The current element being processed in the typed array. index The index of the current element being processed in the typed array. array The typed array some was called upon. thisArg Optional. Value to use as this when executing callback. Return value t...
...it will be passed to callback when invoked, for use as its this value. Otherwise, the value undefined will be passed for use as its this value. The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function. some does not mutate the typed array on which it is called. Polyfill Since there is no global object with the name
TypedArray, polyfilling must be done on an "as needed" basis. // https://tc39.github.io/ecma262/#sec-%
typedarray%.prototype.some if (!Uint8Array.prototype.some) { Object.defineProperty(Uint8Array.prototype, 'some', { value: Array.prototype.some }); } If you need to support truly obsolete JavaScript engines that don't support Object.defineProperty, it's best not to polyfill Array.prototype methods...
... ...
TypedArray.prototype.every() - 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. ...
...pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.every().
TypedArray is one of the typed array types here. 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
typedarray.every(callback[, thisArg]) Parameters callback Function to test for each element, taking three arguments: currentValue The current element being processed in the typed array. index The index of the current element being processed in the typed array. array The typed array every was called upon. thisArg Optional. Value to use as this when executing callback. Return value ...
... ...
TypedArray.prototype.filter() - 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
typedarray.filter(callback[, thisArg]) Parameters callback Function to test each element of the typed array. ...
...ass the test implemented by the provided function. This method has the same algorithm as Array.prototype.filter().
TypedArray is one of the typed array types here. 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
typedarray.filter(callback[, thisArg]) Parameters callback Function to test each element of the typed array. Invoked with arguments (element, index,
typedarray). Return true to keep the element, false otherwise. thisArg Optional Value to use as this when executing callback. Return value A new typed array with the elements that pass the test. Description The filter() method calls a provided callb...
... ...
TypedArray.prototype.find() - JavaScript
See also the findIndex() method, which returns the index of a found element in the typed array instead of its 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. ...
...edArray is one of the typed array types here. See also the findIndex() method, which returns the index of a found element in the typed array instead of its 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
typedarray.find(callback[, thisArg]) Parameters callback Function to execute on each value in the typed array, taking three arguments: element The current element being processed in the typed array. index The index of the current element being processed in the typed array. array The array find was called upon. thisArg Optional. Object to use as this when executing callback. Return...
...undefined if there is no prime number). function isPrime(element, index, array) { var start = 2; while (start <= Math.sqrt(element)) { if (element % start++ < 1) { return false; } } return element > 1; } var uint8 = new Uint8Array([4, 5, 8, 12]); console.log(uint8.find(isPrime)); // 5 Specifications Specification ECMAScript (ECMA-262)The definition of '%
TypedArray%.prototype.find' in that specification. ...
TypedArray.prototype.findIndex() - JavaScript
ovided testing function. Otherwise -1 is returned. See also the find() method, which returns the value of a found element in the typed array instead of its index. 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
typedarray.findIndex(callback[, thisArg]) Parameters callback Function to execute on each value in the typed array, taking three arguments: element The current element being processed in the typed array. index The index of the current element being processed in the typed array. array The typed array findIndex was called upon. thisArg Optional. Object to use as this when executing ca...
...ore the first invocation of callback. Elements that are appended to the typed array after the call to findIndex begins will not be visited by callback. If an existing, unvisited element of the typed array is changed by callback, its value passed to the visiting callback will be the value at the time that findIndex visits that element's index; elements that are deleted are not visited. ...
... ...
TypedArray.prototype.includes() - 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
typedarray.includes(searchElement[, fromIndex]); Parameters searchElement The element to search for. fromIndex Optional. ...
...element, returning true or false as appropriate. This method has the same algorithm as Array.prototype.includes().
TypedArray is one of the typed array types here. 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
typedarray.includes(searchElement[, fromIndex]); Parameters searchElement The element to search for. fromIndex Optional. The position in this array at which to begin searching for searchElement; defaults to 0. Return value A Boolean. Examples Using includes var uint8 = new Uint8Array([1,2,3]); uint8.includes(2); // true uint8.includes(4); // false uint8.includes(3, 3); // false // NaN...
... ...
TypedArray.prototype.indexOf() - 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
typedarray.indexOf(searchElement[, fromIndex = 0]) Parameters searchElement Element to locate in the typed array. ...
...d in the typed array, or -1 if it is not present. This method has the same algorithm as Array.prototype.indexOf().
TypedArray is one of the typed array types here. 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
typedarray.indexOf(searchElement[, fromIndex = 0]) Parameters searchElement Element to locate in the typed array. fromIndex The index to start the search at. If the index is greater than or equal to the typed array's length, -1 is returned, which means the typed array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the typed array. Not...
... ...
TypedArray.prototype.join() - JavaScript
The join() method joins all elements of an array into a string. This method has the same algorithm as Array.prototype.join().
TypedArray is one of the typed array types here. 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
typedarray.join([separator = ',']); Parameters separator Optional. Specifies a string to separate each element. The separator is converted to a string if necessary. If omitted, the typed array elements are separated with a comma (","). ...
...amples and send us a pull request. Syntax
typedarray.join([separator = ',']); Parameters separator Optional. Specifies a string to separate each element. The separator is converted to a string if necessary. If omitted, the typed array elements are separated with a comma (","). Return value A string with all array elements joined. Polyfill Since there is no global object with the name
TypedArray, polyfilling must be done on an "as needed" basis. // https://tc39.github.io/ecma262/#sec-%
typedarray%.prototype.join if (!Uint8Array.prototype.join) { Object.defineProperty(Uint8Array.prototype, 'join', { value: Array.prototype.join }); } If you need to support truly obsolete JavaScript engines that don't support Object.defineProperty, it's best not to polyfill Array.prototype methods...
... ...
TypedArray.prototype.lastIndexOf() - 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. ...
...is searched backwards, starting at fromIndex. This method has the same algorithm as Array.prototype.lastIndexOf().
TypedArray is one of the typed array types here. 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
typedarray.lastIndexOf(searchElement[, fromIndex =
typedarray.length]) Parameters searchElement Element to locate in the typed array. fromIndex Optional. The index at which to start searching backwards. Defaults to the typed array's length, i.e. the whole typed array will be searched. If the index is greater than or equal to the length of the typed array, the whole typed array will be searched. If ne...
... used by the ===, or triple-equals, operator). Examples Using lastIndexOf var uint8 = new Uint8Array([2, 5, 9, 2]); uint8.lastIndexOf(2); // 3 uint8.lastIndexOf(7); // -1 uint8.lastIndexOf(2, 3); // 3 uint8.lastIndexOf(2, 2); // 0 uint8.lastIndexOf(2, -2); // 0 uint8.lastIndexOf(2, -1); // 3 Specifications Specification ECMAScript (ECMA-262)The definition of '
TypedArray.prototype.lastIndexOf' in that specification. ...
TypedArray.prototype.map() - 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. ...
...ovided function on every element in this typed array. This method has the same algorithm as Array.prototype.map().
TypedArray is one of the typed array types here. 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
typedArray.map(mapFn[, thisArg]) Parameters mapFn A callback function that produces an element of the new typed array, taking three arguments: currentValue The current element being processed in the typed array. index Optional The index of the current element being processed in the typed array. array Optional The typed array map() was called upon. thisArg Optional Value to use as...
... ...
TypedArray.prototype.reduce() - 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. ...
...left-to-right) has to reduce it to a single value. This method has the same algorithm as Array.prototype.reduce().
TypedArray is one of the typed array types here. 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
typedarray.reduce(callback[, initialValue]) Parameters callback Function to execute on each value in the typed array, taking four arguments: previousValue The value previously returned in the last invocation of the callback, or initialValue, if supplied (see below). currentValue The current element being processed in the typed array. index The index of the current element being processed ...
...Error would be thrown. If the typed array has only one element (regardless of position) and no initialValue was provided, or if initialValue is provided but the typed array is empty, the solo value would be returned without calling callback. Polyfill This method uses the same algorithm as Array.prototype.reduce(), so the same polyfill can be used here: simply replace Array.prototype.reduce with
TypedArray.prototype.reduce. Examples Sum up all values within an array var total = new Uint8Array([0, 1, 2, 3]).reduce(function(a, b) { return a + b; }); // total == 6 Specifications Specification ECMAScript (ECMA-262)The definition of '%
TypedArray%.prototype.reduce' in that specification. ...
TypedArray.prototype.reduceRight() - JavaScript
Syntax
typedarray.reduceRight(callback[, initialValue]) Parameters callback Function to execute on each value in the typed array, taking four arguments: previousValue The value previously returned in the last invocation of the callback, or initialValue, if supplied (see below). ...
...uceRight method executes the callback function once for each element present in the typed array, excluding holes in the typed array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the typed array over which iteration is occurring. The call to the reduceRight callback would look something like this:
typedarray.reduceRight(function(previousValue, currentValue, index,
typedarray) { // ... }); The first time the function is called, the previousValue and currentValue can be one of two values. If an initialValue was provided in the call to reduceRight, then previousValue will be equal to initialValue and currentValue will be equal to the last value in the typed array. If no initialValue was provided, th...
... ...
TypedArray.prototype.sort() - 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. ...
... has the same algorithm as Array.prototype.sort(), except that sorts the values numerically instead of as strings.
TypedArray is one of the typed array types here. 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
typedarray.sort([compareFunction]) Parameters compareFunction Optional Specifies a function that defines the sort order. Return value The sorted typed array. Examples Using sort For more examples, see also the Array.prototype.sort() method. let numbers = new Uint8Array([40, 1, 5, 200]); numbers.sort(); // Uint8Array [ 1, 5, 40, 200 ] // Unlike plain Arrays, a compare function is not required // ...
... ...
TypedArray.prototype.subarray() - 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
typedarray.subarray([begin [,end]]) Parameters begin Optional Element to begin at. The offset is inclusive. The whole array will be included in the new view if this value is not specified. end Optional Element to end at. The offset is exclusive. ...
...yntax
typedarray.subarray([begin [,end]]) Parameters begin Optional Element to begin at. The offset is inclusive. The whole array will be included in the new view if this value is not specified. end Optional Element to end at. The offset is exclusive. If not specified, all elements from the one specified by begin to the end of the array are included in the new view. Return value A new
TypedArray object. Description The range specified by begin and end is clamped to the valid index range for the current array; if the computed length of the new array would be negative, it's clamped to zero. If either begin or end is negative, it refers to an index from the end of the array instead of from the beginning. Also note that this is creating a new view on the existing buffer; changes to the ne...
...ct the original object and vice versa. Examples Using the subarray method var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.set([1,2,3]); console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ] var sub = uint8.subarray(0,4); console.log(sub); // Uint8Array [ 1, 2, 3, 0 ] Specifications Specification ECMAScript (ECMA-262)The definition of '
TypedArray.prototype.subarray' in that specification. ...
get TypedArray[@@species] - JavaScript
The
TypedArray[@@species] accessor property returns the constructor of a typed array. Description The species accessor property returns the default constructor for typed array objects. Subclass constructors may over-ride it to change the constructor assignment. Examples Species in ordinary objects The species property returns the default constructor function, which is one of the typed array constructors for a given typed array object: Int8Array[Symbol.species]; // function Int8Array() Uint8Array[Symbol.species]; // function Uint8Array() Float32Array[Symbol.species]; // function Float32Array() Species in derived objects In a derived collection object (e.g. your custom typed array My
TypedArray), the My
TypedArray species is the My
TypedArray constructor. However, you might want to overwri...
...rray[Symbol.species]; // function Uint8Array() Float32Array[Symbol.species]; // function Float32Array() Species in derived objects In a derived collection object (e.g. your custom typed array My
TypedArray), the My
TypedArray species is the My
TypedArray constructor. However, you might want to overwrite this, in order to return a parent typed array object in your derived class methods: class My
TypedArray extends Uint8Array { // Overwrite My
TypedArray species to the parent Uint8Array constructor static get [Symbol.species]() { return Uint8Array; } } Specifications Specification ECMAScript (ECMA-262)The definition of 'get %
TypedArray% [ @@species ]' in that specification. ...
TypedArray.BYTES_PER_ELEMENT - JavaScript
The
TypedArray.BYTES_PER_ELEMENT property represents the size in bytes of each element in an typed 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. Property attributes of
TypedArray.BYTES_PER_ELEMENT Writable no Enumerable no Configurable no Description
TypedArray objects differ from each other in the number of bytes per element and in the way the bytes are interpreted. The BYTES_PER_ELEMENT constant contains the number of bytes each element in the given
TypedArray has. Examples Using BYTES_PER_ELEMENT Int8Array.BYTE...
... ...
TypedArray.prototype.buffer - JavaScript
The buffer accessor property represents the ArrayBuffer referenced by a
TypedArray at construction time. 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 buffer property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is established when the
TypedArray is constructed and cannot be changed.
TypedArray is one of the
TypedArray objects. Examples Using the buffer property var buffer = new ArrayBuffer(8); var uint16 = new Uint16Array(buffer); uint16.buffer; // ArrayBuffer { byteLength: 8 } Specifications Specification ...
...only read this property. The value is established when the
TypedArray is constructed and cannot be changed.
TypedArray is one of the
TypedArray objects. Examples Using the buffer property var buffer = new ArrayBuffer(8); var uint16 = new Uint16Array(buffer); uint16.buffer; // ArrayBuffer { byteLength: 8 } Specifications Specification ECMAScript (ECMA-262)The definition of '
TypedArray.prototype.buffer' in that specification. ...
TypedArray.prototype.byteLength - JavaScript
urce 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 byteLength property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is established when a
TypedArray is constructed and cannot be changed. If the
TypedArray is not specifying an byteOffset or a length, the length of the referenced ArrayBuffer will be returned.
TypedArray is one of the
TypedArray objects. Examples Using the byteLength property var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.byteLength; // 8 (matches the byteLength of the buffer) var uint8 = new Uin...
... ...
TypedArray.prototype.copyWithin() - JavaScript
The copyWithin() method copies the sequence of array elements within the array to the position starting at target. The copy is taken from the index positions of the second and third arguments start and end. The end argument is optional and defaults to the length of the array. This method has the same algorithm as Array.prototype.copyWithin.
TypedArray is one of the typed array types here. 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
typedarray.copyWithin(target, start[, end = this.length]) Parameters target Target start index position where to copy the elements to. start Source start index position where...
...y.prototype.copyWithin for more details. Examples Using copyWithin var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.set([1,2,3]); console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ] uint8.copyWithin(3,0,3); console.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ] Specifications Specification ECMAScript (ECMA-262)The definition of '
TypedArray.prototype.copyWithin' in that specification. ...
TypedArray.prototype.forEach() - JavaScript
Syntax
typedarray.forEach(callback[, thisArg]) Parameters callback Function that produces an element of the new typed array, taking three arguments: currentValue The current element being processed in the typed array. index The index of the current element being processed in the array. array The array forEach() was called upon. thisArg Optional. Value to use as this when executing callback. Return value undefined. ...
... ...
TypedArray.prototype.length - JavaScript
e 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 length property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is established when a
TypedArray is constructed and cannot be changed. If the
TypedArray is not specifying an byteOffset or a length, the length of the referenced ArrayBuffer will be returned.
TypedArray is one of the
TypedArray objects. Examples Using the length property var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.length; // 8 (matches the length of the buffer) var uint8 = new Uint8Array(buff...
... ...
TypedArray.prototype.reverse() - JavaScript
The reverse() method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as Array.prototype.reverse().
TypedArray is one of the typed array types here. 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
typedarray.reverse(); Return value The reversed array. ...
... ...
TypedArray.prototype.toLocaleString() - JavaScript
The toLocaleString() method returns a string representing the elements of the typed array. The elements are converted to strings and are separated by a locale-specific string (such as a comma ","). This method has the same algorithm as Array.prototype.toLocaleString() and, as the typed array elements are numbers, the same algorithm as Number.prototype.toLocaleString() applies for each element.
TypedArray is one of the typed array types here. Syntax
typedarray.toLocaleString([locales [, options]]); Parameters The locales and options arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. In implementations, which ignore the locales and options arguments, the locale used and the form of the string returned are entire...
... ...
TypedArray.prototype.toString() - JavaScript
The toString() method returns a string representing the specified array and its elements. This method has the same algorithm as Array.prototype.toString().
TypedArray is one of the typed array types here. 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
typedarray.toString() Return value A string representing the elements of the typed array. Examples The
TypedArray objects override the toString method of Object. For
TypedArray objects, the toString method joins the array and returns one string containing each typed array element separated by commas. For example, the following code creates a typed array and uses...
...xample, the following code creates a typed array and uses toString to convert the array to a string. var numbers = new Uint8Array([2, 5, 8, 1, 4]) numbers.toString(); // "2,5,8,1,4" JavaScript calls the toString method automatically when a typed array is to be represented as a text value or when an array is referred to in a string concatenation. Compatibility If a browser doesn't support the
TypedArray.prototype.toString() method yet, JavaScript will call the toString method of Object: var numbers = new Uint8Array([2, 5, 8, 1, 4]) numbers.toString(); // "[object Uint8Array]" Specifications Specification ECMAScript (ECMA-262)The definition of 'Array.prototype.toString' in that specification. ...
TypedArray.prototype.byteOffset - JavaScript
The byteOffset accessor property represents the offset (in bytes) of a typed array from the start of its ArrayBuffer. Description The byteOffset property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is established when a
TypedArray is constructed and cannot be changed.
TypedArray is one of the
TypedArray objects. Examples Using the byteOffset property var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.byteOffset; // 0 (no offset specified) var uint8 = new Uint8Array(buffer, 3); uint8.byteOffset; // 3 (as specified when constructing Uint8Array) Specifications Specification ECMAScript (ECMA-262)The definition of '
TypedArray.prototype.byteOffset' in that specification. ...
StringView - Archive of obsolete content
*/ fTAView = vInput.constructor; nInptLen = vInput.length; aWhole = vInput.byteOffset === 0 && vInput.length === ( fTAView === Uint32Array ? vInput.buffer.byteLength >>> 2 : fTAView === Uint16Array ? vInput.buffer.byteLength >>> 1 : ...
...*/ aWhole = new fTAView(vInput); nInptLen = aWhole.length; aRaw = nStartIdx === 0 && (!isFinite(nLength) || nLength === nInptLen) ? aWhole : aWhole.subarray(nStartIdx, isFinite(nLength) ? nStartIdx + nLength : nInptLen); } break typeSwitch; default: /* the input argument is a number, a boolean or a functi...
...reated. */ aWhole = new fTAView(vInput); nInptLen = aWhole.length; aRaw = nStartIdx === 0 && (!isFinite(nLength) || nLength === nInptLen) ? aWhole : aWhole.subarray(nStartIdx, isFinite(nLength) ? nStartIdx + nLength : nInptLen); } break typeSwitch; default: /* the input argument is a number, a boolean or a function: a new
typedArray will be created. */ aWhole = aRaw = new fTAView(Number(vInput) || 0); } if (nTranscrType < 8) { var vSource, nOutptLen, nCharStart, nCharEnd, nEndIdx, fGetInptChrSize, fGetInptChrCode; if (nTranscrType & 4) { /* input is string */ vSource = vInput; nOutptLen = nInptLen = vSource.length; nTranscrType ^= this.encoding === "UTF-32" ? 0 : 2; /* ...or...:...
...And 6 more matches
WebIDL bindings
doSomething(const Sequence<OwningNonNull<MyClass> >& arg); already_AddRefed<MyClass> doTheOther(const Sequence<RefPtr<MyClass> >& arg); already_Addrefed<MyClass> GetNullableAttr(); MyClass* SomeOtherAttr(); MyClass* SomeYetOtherAttr(); // Don't have to return already_AddRefed! ...
...Refed<MyClass> doTheOther(const Sequence<RefPtr<MyClass> >& arg); already_Addrefed<MyClass> GetNullableAttr(); MyClass* SomeOtherAttr(); MyClass* SomeYetOtherAttr(); // Don't have to return already_AddRefed! "SpiderMonkey" interfaces Typed array, array buffer, and array buffer view arguments are represented by the objects in
TypedArray.h. ...
...r<MyClass> >& arg); already_Addrefed<MyClass> GetNullableAttr(); MyClass* SomeOtherAttr(); MyClass* SomeYetOtherAttr(); // Don't have to return already_AddRefed! "SpiderMonkey" interfaces Typed array, array buffer, and array buffer view arguments are represented by the objects in
TypedArray.h. For example, this WebIDL: interface Test { void pass
TypedArrayBuffer(ArrayBuffer arg); void pass
TypedArray(ArrayBufferView arg); void passInt16Array(Int16Array? arg); } will correspond to these C++ function declarations: void Pass
TypedArrayBuffer(const ArrayBuffer& arg); void Pass
TypedArray(const ArrayBufferView& arg); void PassInt16Array(const Nullable<Int16Array>& arg); Typed array return values become a JS::MutableHandle<JSObject*> out param appended to the argument list. This comes after al...
...And 2 more matches
Float32Array() constructor - JavaScript
ing to the C float data type) in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). ...
...yntax (that is, using bracket notation). Syntax new Float32Array(); // new in ES2017 new Float32Array(length); new Float32Array(
typedArray); new Float32Array(object); new Float32Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer ...
...And 2 more matches
Float64Array() constructor - JavaScript
ng to the C double data type) in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). ...
...yntax (that is, using bracket notation). Syntax new Float64Array(); // new in ES2017 new Float64Array(length); new Float64Array(
typedArray); new Float64Array(object); new Float64Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer ...
...And 2 more matches
Int16Array() constructor - JavaScript
s-complement 16-bit signed integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). ...
...ay index syntax (that is, using bracket notation). Syntax new Int16Array(); // new in ES2017 new Int16Array(length); new Int16Array(
typedArray); new Int16Array(object); new Int16Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer...
...And 2 more matches
Int32Array() constructor - JavaScript
s-complement 32-bit signed integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). ...
...ay index syntax (that is, using bracket notation). Syntax new Int32Array(); // new in ES2017 new Int32Array(length); new Int32Array(
typedArray); new Int32Array(object); new Int32Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer...
...And 2 more matches
Uint16Array() constructor - JavaScript
The Uint16Array() typed array constructor creates an array of 16-bit unsigned integers in the platform byte order. Syntax new Uint16Array(); // new in ES2017 new Uint16Array(length); new Uint16Array(
typedArray); new Uint16Array(object); new Uint16Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array wil...
... object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. ...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer...
...And 2 more matches
Uint32Array() constructor - JavaScript
rray of 32-bit unsigned integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). ...
...dex syntax (that is, using bracket notation). Syntax new Uint32Array(); // new in ES2017 new Uint32Array(length); new Uint32Array(
typedArray); new Uint32Array(object); new Uint32Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer...
...And 2 more matches
Uint8ClampedArray() constructor - JavaScript
[0,255], 0 or 255 will be set instead; if you specify a non-integer, the nearest integer will be set. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). ...
...cket notation). Syntax new Uint8ClampedArray(); // new in ES2017 new Uint8ClampedArray(length); new Uint8ClampedArray(
typedArray); new Uint8ClampedArray(object); new Uint8ClampedArray(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer...
...And 2 more matches
JIT Optimization Outcomes
s been removed or transferred to a worker). TypedObjectArrayRange Failed to do range check of element access on a typed object. AccessNotDense AccessNotSimdObject The observed type of the target of the property access doesn't guarantee that it is an SIMD object. AccessNotTypedObject The observed type of the target of the property access doesn't guarantee that it is a TypedObject. AccessNot
TypedArray AccessNotString Static
TypedArrayUint32 Static
TypedArrayCantComputeMask OutOfBounds GetElemStringNotCached NonNativeReceiver IndexType SetElemNonDenseNonTANotCached NoSimdJitSupport Optimization failed because SIMD JIT support was not enabled. SimdTypeNotOptimized The type observed as being retrieved from this property access did not match an optimizable type. UnknownSimdProperty The...
... one of the optimizable property names. HasCommonInliningPath Inlined DOM Monomorphic Polymorphic Inline Cache Outcomes Outcomes describing inline cache stubs that were generated. ...
... CantInlineGeneric CantInlineClassConstructor CantInlineExceededDepth CantInlineExceededTotalBytecodeLength CantInlineBigCaller CantInlineBigCallee CantInlin...
... CantInlineGeneric CantInlineClassConstructor CantInlineExceededDepth CantInlineExceededTotalBytecodeLength CantInlineBigCaller CantInlineBigCallee CantInlineBigCalleeInlinedBytecodeLength CantInlineNotHot CantInlineNotInDispatch CantInlineNativeBadType CantIn...
Blob - Web APIs
s data. It then calls URL.createObjectURL() to convert the blob into a URL. HTML <p>This example creates a typed array containing the ASCII codes for the space character through the letter Z, then converts it to an object URL. A link to open that object URL is created. ...
...ed object URL.</p> JavaScript The main piece of this code for example purposes is the
typedArrayToURL() function, which creates a Blob from the given typed array and returns an object URL for it. Having converted the data into an object URL, it can be used in a number of ways, including as the value of the <img> element's src attribute (assuming the data contains an image, of course). ...
...p> JavaScript The main piece of this code for example purposes is the
typedArrayToURL() function, which creates a Blob from the given typed array and returns an object URL for it. Having converted the data into an object URL, it can be used in a number of ways, including as the value of the <img> element's src attribute (assuming the data contains an image, of course). ...
...s is the
typedArrayToURL() function, which creates a Blob from the given typed array and returns an object URL for it. Having converted the data into an object URL, it can be used in a number of ways, including as the value of the <img> element's src attribute (assuming the data contains an image, of course). function
typedArrayToURL(
typedArray, mimeType) { return URL.createObjectURL(new Blob([
typedArray.buffer], {type: mimeType})) } const bytes = new Uint8Array(59); for(let i = 0; i < 59; i++) { bytes[i] = 32 + i; } const url =
typedArrayToURL(bytes, 'text/plain'); const link = document.createElement('a'); link.href = url; link.innerText = 'Open the array URL'; document.body.appendChild(link); Result Click the link in the example to see the browser decode the object URL. Extracting d...
BigInt64Array() constructor - JavaScript
is, an array of 64-bit signed integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0n. Once established, you can reference elements in the array using the object's methods, or by using standard array index syntax (that is, using bracket notation). ...
...rray index syntax (that is, using bracket notation). Syntax new BigInt64Array(); new BigInt64Array(length); new BigInt64Array(
typedArray); new BigInt64Array(object); new BigInt64Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer ...
...y length is omitted, the remainder of buffer is viewed. ...
BigUint64Array() constructor - JavaScript
an array of 64-bit unsigned integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0n. Once established, you can reference elements in the array using the object's methods, or by using standard array index syntax (that is, using bracket notation). ...
...index syntax (that is, using bracket notation). Syntax new BigUint64Array(); new BigUint64Array(length); new BigUint64Array(
typedArray); new BigUint64Array(object); new BigUint64Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When call...
...y of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer ...
... is omitted, the remainder of buffer is viewed. ...
Int8Array() constructor - JavaScript
The Int8Array() constructor creates a typed array of twos-complement 8-bit signed integers. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). Syntax new Int8Array(); // new in ES2017 new Int8Array(length); new Int8Array(
typedArray); new Int8Array(object); new Int8Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. ...
..., byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length a...
...ted, all of buffer is viewed; if only length is omitted, the remainder of buffer is viewed. ...
... ...
Uint8Array() constructor - JavaScript
The Uint8Array() constructor creates a typed array of 8-bit unsigned integers. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). Syntax new Uint8Array(); // new in ES2017 new Uint8Array(length); new Uint8Array(
typedArray); new Uint8Array(object); new Uint8Array(buffer [, byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each val...
..., byteOffset [, length]]); Parameters length When called with a length argument, an internal array buffer is created in memory, of size length multiplied by BYTES_PER_ELEMENT bytes, containing zeros.
typedArray When called with a
typedArray argument, which can be an object of any of the typed array types (such as Int32Array), the
typedArray gets copied into a new typed array. Each value in
typedArray is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the
typedArray argument. object When called with an object argument, a new typed array is created as if by the
TypedArray.from() method. buffer, byteOffset, length When called with a buffer, and optionally a byteOffset and a length a...
...l of buffer is viewed; if only length is omitted, the remainder of buffer is viewed. ...
... ...
JSProtoKey
Some of them are Nightly only (depends on each option). See Also bug 789635 bug 645416 - added JSProto_Symbol bug 769872 - added JSProto_Intl...
...Some of them are Nightly only (depends on each option). See Also bug 789635 bug 645416 - added JSProto_Symbol bug 769872 - added JSProto_Intl bug 792439 -...
...y) MXR Search for JSProto_SharedFloat32Array JSProto_SharedFloat64Array SharedFloat64Array (Nightly only) MXR Search for JSProto_SharedFloat64Array JSProto_SharedUint8ClampedArray SharedUint8ClampedArray (Nightly only) MXR Search for JSProto_SharedUint8ClampedArray JSProto_
TypedArray TypedArray Added in SpiderMonkey 38 MXR Search for JSProto_
TypedArray JSProto_Atomics Atomics (Nightly only) MXR Search for JSProto_Atomics Description Each of these types corresponds to standard objects in JavaScript. Some of them are Nightly only (depends on each option). See Also bug 789635 bug 645416 - added JSProto_Symbol bug 769872 - added JSProto_Intl bug 792439 - added JSProto_WeakSet bug 896116 - added JSProto_
TypedArray b...
Atomics.add() - JavaScript
rray and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back. 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. ...
...ition. This atomic operation guarantees that no other write happens until the modified value is written back. 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 Atomics.add(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to add a value to. value The number to add. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a Ra...
... Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to add a value to. value The number to add. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if index is out of bounds in the
typedArray. Examples Using add() const sab = new SharedArrayBuffer(1024); const ta = new Uint8Array(sab); Atomics.add(ta, 0, 12); // returns 0, the old value Atomics.load(ta, 0); // 12 Specifications Specification ECMAScript (ECMA-262)The definition of 'Atomics.add' in that specification. ...
Atomics.and() - JavaScript
ray, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back. 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 Atomics.and(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to compute the bitwise AND. value The number to compute the bitwise AND with. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a Ty...
... Description The bitwise AND operation only yields 1, if both a and b are 1. ...
... Description The bitwise AND operation only yields 1, if both a and b are 1. ...
Atomics.exchange() - JavaScript
e at that position. This atomic operation guarantees that no other write happens between the read of the old value and the write of the new 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. ...
...guarantees that no other write happens between the read of the old value and the write of the new 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 Atomics.exchange(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to exchange a value. value The number to exchange. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Thro...
...rray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to exchange a value. value The number to exchange. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if index is out of bounds in the
typedArray. Examples Using exchange() const sab = new SharedArrayBuffer(1024); const ta = new Uint8Array(sab); Atomics.exchange(ta, 0, 12); // returns 0, the old value Atomics.load(ta, 0); // 12 Specifications Specification ECMAScript (ECMA-262)The definition of 'Atomics.exchange' in that specification. ...
Atomics.or() - JavaScript
rray, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back. 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 Atomics.or(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to compute the bitwise OR. value The number to compute the bitwise OR with. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a Type...
... Description The bitwise OR operation yields 1, if either a or b are 1. ...
... Description The bitwise OR operation yields 1, if either a or b are 1. ...
Atomics.sub() - JavaScript
rray and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back. 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. ...
...ition. This atomic operation guarantees that no other write happens until the modified value is written back. 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 Atomics.sub(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to subtract a value from. value The number to subtract. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. ...
... Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to subtract a value from. value The number to subtract. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if index is out of bounds in the
typedArray. Examples Using sub const sab = new SharedArrayBuffer(1024); const ta = new Uint8Array(sab); ta[0] = 48; Atomics.sub(ta, 0, 12); // returns 48, the old value Atomics.load(ta, 0); // 36 Specifications Specification ECMAScript (ECMA-262)The definition of 'Atomics.sub' in that specification. ...
Atomics.xor() - JavaScript
ray, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back. 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 Atomics.xor(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to compute the bitwise XOR. value The number to compute the bitwise XOR with. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a Ty...
... Description The bitwise XOR operation yields 1, if a and b are different. ...
... Description The bitwise XOR operation yields 1, if a and b are different. ...
JIT Optimization Strategies
are arrays which do not have any 'holes'. This means that the array has valid values for all indexes from 0 to length-1. GetElem_TypedStatic Attempts to optimize element accesses on a typed array that can be determined to always refer to the same array object. If this optimization succeeds, the 'array' object is treated as a constant, and is not looked up or retrieved from a variable. GetElem_
TypedArray Attempts to optimize element accesses on a typed array. GetElem_String Attempts to optimize element accesses on a string. GetElem_Arguments Attempts to optimize element accesses on the arguments special object available in functions. This optimization only works if the arguments object is used in well-understood ways within the function. The function containing the arguments.length is allowe...
...de the optimization process. SetElement SetElem_TypedObject Attempts to optimized element writes on array Typed Objects. SetElem_TypedStatic Attempts to optimize element writes on a typed array that can be determined to always refer to the same array object. If this optimization succeeds, the 'array' object is treated as a constant, and is not looked up or retrieved from a variable. SetElem_
TypedArray Attempts to optimize element writes on a typed array. SetElem_Dense Attempts to optimize element writes on densely packed array objects. Dense arrays are arrays which do not have any 'holes'. This means that the array has valid values for all indexes from 0 to length-1. SetElem_Arguments Attempts to optimize element writes to the arguments special object available in functions. This optimiza...
Index - Web APIs
ns, currentTime, waapi, web animations api The currentTime read-only property of the Web Animations API's AnimationTimeline interface returns the timeline's current time in milliseconds, or null if the timeline is inactive. 98 ArrayBufferView API, Interface, JavaScript, Reference, Typed Arrays ArrayBufferView is a helper type representing any of the following JavaScript
TypedArray types: 99 Attr API, DOM The Attr interface represents one of a DOM element's attributes as an object. In most DOM methods, you will directly retrieve the attribute as a string (e.g., Element.getAttribute()), but certain functions (e.g., Element.getAttributeNode()) or means of iterating return Attr types. 100 Attr.localName API, DOM, Property, Reference Th...
...dgetState.time API, BudgetState, Property, Reference, Time, Web Budget API The time read-only property of the BudgetState interface returns a timestamp at which the budgetAt value is valid. 379 BufferSource API, Interface, JavaScript, Reference, Typed Arrays BufferSource is a typedef used to represent objects that are either themselves an ArrayBuffer, or which are a
TypedArray providing an ArrayBufferView. 380 ByteLengthQueuingStrategy API, ByteLengthqueueingStrategy, Experimental, Interface, Reference, Streams The ByteLengthQueuingStrategy interface of the the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams. 381 ByteLengthQueuingStrategy.ByteLengthQueuingStrategy() API, ByteLen...
Indexed collections - JavaScript
Array object An array is an ordered list of values that you refer to with a name and an index. For example, consider an array called emp, which contains employees' names indexed by their numerical employee number. So emp[0] would be employee number zero, emp[1] employee number one, and so on. JavaScript does not have an explicit array data type. ...
... << PreviousNext >> ...
TypeError: Reduce of empty array with no initial value - JavaScript
The JavaScript exception "reduce of empty array with no initial value" occurs when a reduce function is used. Message TypeError: reduce of empty array with no initial value Error type TypeError What went wrong? In JavaScript, there are several reduce functions: Array.prototype.reduce(), Array.prototype.reduceRight() and
TypedArray.prototype.reduce(),
TypedArray.prototype.reduceRight()). These functions optionally take an initialValue (which will be used as the first argument to the first call of the callback). However, if no initial value is provided, it will use the first element of the Array or
TypedArray as the initial value. This error is raised when an empty array is provided because no initial value can be returned in that case. Examples Invalid cases This problem appears fre...
...Thus leaving none to be used as the initial value. ...
Atomics.compareExchange() - JavaScript
equal to the expected value or not. This atomic operation guarantees that no other write happens until the modified value is written back. 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 Atomics.compareExchange(
typedArray, index, expectedValue, replacementValue) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to exchange a value. expectedValue The value to check for equality. replacementValue The number to exchange. Return value The old value at the giv...
...ctedValue, replacementValue) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to exchange a value. expectedValue The value to check for equality. replacementValue The number to exchange. Return value The old value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if index is out of bounds in the
typedArray. Examples Using compareExchange() const sab = new SharedArrayBuffer(1024); const ta = new Uint8Array(sab); ta[0] = 7; Atomics.compareExchange(ta, 0, 7, 12); // returns 7, the old value Atomics.load(ta, 0); // 12 Specifications ...
Atomics.store() - JavaScript
The static Atomics.store() method stores a given value at the given position in the array and returns that 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 Atomics.store(
typedArray, index, value) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to store a value in. value The number to store. Return value The value that has been stored. Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if i...
...ay. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to store a value in. value The number to store. Return value The value that has been stored. Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if index is out of bounds in the
typedArray. Examples Using store() var sab = new SharedArrayBuffer(1024); var ta = new Uint8Array(sab); Atomics.store(ta, 0, 12); // 12 Specifications Specification ECMAScript (ECMA-262)The definition of 'Atomics.store' in that specification. ...
Atomics.wait() - JavaScript
The static Atomics.wait() method verifies that a given position in an Int32Array still contains a given value and if so sleeps, awaiting a wakeup or a timeout. It returns a string which is either "ok", "not-equal", or "timed-out". Note: This operation only works with a shared Int32Array and may not be allowed on the main thread. Syntax Atomics.wait(
typedArray, index, value[, timeout]) Parameters
typedArray A shared Int32Array. index The position in the
typedArray to wait on. value The expected value to test. timeout Optional Time to wait in milliseconds. Infinity, if no time is provided. Return value A String which is either "ok", "not-equal", or "timed-out". Exceptions Throws a TypeError, if
typedArray is not a shared Int32Array. Throws a RangeError, if index is out of bou...
... Examples Using wait() Given a shared Int32Array: const sab = new SharedArrayBuffer(1024); const int32 = new Int32Array(sab); A reading thread is sleeping and waiting on location 0 which is expected to be 0. As long as that is true, it will not go on. ...
Int16Array - JavaScript
s a new Array Iterator object that contains the values for each index in the array. ...
... ...
Int32Array - JavaScript
s a new Array Iterator object that contains the values for each index in the array. ...
... ...
Int8Array - JavaScript
Returns a new Array Iterator object that contains the values for each index in the array. ...
... ...
Object.prototype.toLocaleString() - JavaScript
tring representing the object. Description Object's toLocaleString returns the result of calling toString(). This function is provided to give objects a generic toLocaleString method, even though not all may use it. See the list below. ...
...enting the object. Description Object's toLocaleString returns the result of calling toString(). This function is provided to give objects a generic toLocaleString method, even though not all may use it. See the list below. ...
Uint8Array - JavaScript
ns a new Array Iterator object that contains the values for each index in the array. ...
... ...
Uint8ClampedArray - JavaScript
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 an array var arr = new Uint8ClampedArray([21,31]); console.log(arr[1]); // 31 // From another
TypedArray var x = new Uint8ClampedArray([21, 31]); var y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(8); var z = new Uint8ClampedArray(buffer, 1, 4); // From an iterable var iterable = function*(){ yield* [1,2,3]; }(); var uintc8 = new Uint8ClampedArray(iterable); // Uint8ClampedArray[1, 2, 3] Specifications Specification E...
... ...
for...of - JavaScript
It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object. 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. ...
...) { console.log(value); } // 10 // 20 // 30 You can use let instead of const too, if you reassign the variable inside the block. ...
Index - Archive of obsolete content
more general Proxy object instead. 2006 Array.unobserve() Array, JavaScript, Method, Obsolete The Array.unobserve() method was used to remove observers set by Array.observe(), but has been deprecated and removed from Browsers. You can use the more general Proxy object instead. 2007 ArrayBuffer.transfer() ArrayBuffer, Experimental, JavaScript, Method, Reference,
TypedArrays The static ArrayBuffer.transfer() method returns a new ArrayBuffer whose contents have been taken from the oldBuffer's data and then is either truncated or zero-extended by newByteLength. If newByteLength is undefined, the byteLength of the oldBuffer is used. This operation leaves oldBuffer in a detached state. 2008 Date.prototype.toLocaleFormat() Date, JavaScript, Method, N...
ECMAScript 2016 to ES.Next support in Mozilla - Archive of obsolete content
is year, the ES2019 specification will be released and ES2020 is the current ECMAScript draft specification. You can see the latest proposals on the tc39/ecma262 GitHub repository. A channel for feedback on ECMAScript standards is es-discuss. Below is a list of features in ES2016+ and what version of Firefox they were implemented in. ...
Type conversion
onverted value ctypes.char.ptr JS string pointer to temporary allocated null-terminated UTF8 string ctypes.signed_char.ptr ctypes.unsigned_char.ptr ctypes.char16.ptr JS string pointer to temporary allocated null-terminated UTF16 string any pointer types any ArrayBuffer object pointer to the ArrayBuffer ctypes.voidptr_t any
TypedArray/DataView object pointer to the
TypedArray/DataView ctypes.char.ptr ctypes.int8_t.ptr Int8Array pointer to the Int8Array ctypes.uint8_t.ptr UInt8Array pointer to the UInt8Array UIntClamped8Array pointer to the UIntClamped8Array ctypes.int16_t.ptr Int16Array pointer to the Int16Array ctypes.uint16_t.ptr UInt16Array ...
Working with ArrayBuffers
view for an ArrayBuffer. The following codeblock provides a basic example of getting and setting Uint8ClampedArray and ArrayBuffer of ImageData: // context is a CanvasRenderingContext2D of some canvas var imageData = context.getImageData(x, y, w, h); var array = imageData.data; // array is a Uint8ClampedArray var buffer = imageData.data.buffer; // buffer is a ArrayBuffer // incomingBuffer is a
TypedArray var imageData2 = context.createImageData(w, h); imageData2.data.set(incomingBuffer); Further, if you have a byte array pixelBuffer, and you need to create ImageData from it. The data property holds an array of bytes. We start with the following: // pixelBuffer is a pointer to a RGBA pixel buffer of 400x400 image. pixelBuffer.toString(); // "ctypes.uint8_t.ptr(ctypes.UInt64("0x352e0000"))" va...
AnalyserNode.frequencyBinCount - Web APIs
e interface is an unsigned integer half that of the AnalyserNode.fftSize. This generally equates to the number of data values you will have to play with for the visualization. Syntax var arrayLength = analyserNode.frequencyBinCount; Value An unsigned integer, equal to the number of values that AnalyserNode.getByteFrequencyData() and AnalyserNode.getFloatFrequencyData() copy into the provided
TypedArray. For technical reasons related to how the Fast Fourier transform is defined, it is always half the value of AnalyserNode.fftSize. Therefore, it will be one of 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, and 16384. Example The following example shows basic usage of an AudioContext to create an AnalyserNode, then requestAnimationFrame and <canvas> to collect frequency data repeatedly and ...
ArrayBufferView - Web APIs
This is a helper type to simplify the specification; it isn't an interface, and there are no objects implementing it. ...
BufferSource - Web APIs
This is a helper type to simplify the specification. It isn't an interface and there are no objects implementing it. ...
Crypto.getRandomValues() - Web APIs
m number generator seeded with a value with enough entropy. The pseudo-random number generator algorithm (PRNG) may vary across user agents, but is suitable for cryptographic purposes. Implementations are required to use a seed with enough entropy, like a system-level entropy source. getRandomValues() is the only member of the Crypto interface which can be used from an insecure context. Syntax
typedArray = cryptoObj.getRandomValues(
typedArray); Parameters
typedArray An integer-based
TypedArray, that is an Int8Array, a Uint8Array, an Int16Array, a Uint16Array, an Int32Array, or a Uint32Array. All elements in the array are overwritten with random numbers. Return value The same array passed as
typedArray but with its contents replaced with the newly generated random numbers. Note that typedA...
Crypto - Web APIs
erty, which is a Crypto object. Properties This interface implements properties defined on RandomSource. Crypto.subtle Read only Secure context Returns a SubtleCrypto object providing access to common cryptographic primitives, like hashing, signing, encryption, or decryption. Methods This interface implements methods defined on RandomSource. Crypto.getRandomValues() Fills the passed
TypedArray with cryptographically sound random values. Usage notes You should avoid using the Web Crypto API on insecure contexts, even though the Crypto interface is present on insecure contexts, as is the Window.crypto property. In addition, the Crypto method getRandomValues() is available on insecure contexts, but the subtle property is not. In general, you probably should just treat Crypto as availa...
SubtleCrypto.importKey() - Web APIs
details. Syntax const result = crypto.subtle.importKey( format, keyData, algorithm, extractable, usages ); Parameters format is a string describing the data format of the key to import. It can be one of the following: raw: Raw format. pkcs8: PKCS #8 format. spki: SubjectPublicKeyInfo format. jwk: JSON Web Key format. keyData is an ArrayBuffer, a
TypedArray, a DataView, or a JSONWebKey object containing the key in the given format. algorithm is a dictionary object defining the type of key to import and providing extra algorithm-specific parameters. For RSASSA-PKCS1-v1_5, RSA-PSS, or RSA-OAEP: Pass an RsaHashedImportParams object. For ECDSA or ECDH: Pass an EcKeyImportParams object. For HMAC: Pass an HmacImportParams object. For AES-C...
TextEncoder.prototype.encodeInto() - Web APIs
an string.length if uint8Array did not have enough space. written The number of bytes modified in the destination Uint8Array. The bytes written are guaranteed to form complete UTF-8 byte sequences. Encode Into A Specific Position encoder.encodeInto always puts its output at the start of the array. However, it is sometimes useful to make the output start at a particular index. The solution is
TypedArray.prototype.subarray(). Observe. var encoder = new TextEncoder; function encodeIntoAtPosition(string, u8array, position) { return encoder.encodeInto(string, position ? u8array.subarray(position|0) : u8array); } var u8array = new Uint8Array(8); encodeIntoAtPosition("hello", u8array, 2); console.log( "" + u8array.join() ); // 0,0,104,101,108,108,111,0 Buffer Sizing To convert a JavaScript st...
TextEncoder - Web APIs
8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding. This is potentially more performant than the older encode() method. Polyfill The below polyfill is compliant with the standard and therefore only supports UTF-8. It is designed to work in IE5 "out of the box". However, in IE5-IE9, it will return a regular Array instead of a
TypedArray. In those cases a polyfill might be impractical for large strings. Finally, note that you should run the below code through a minifier (especially closure compiler) to turn sequences like 0x1e << 3 into 0xf0. These sequences are not already precomputed because they serve to aesthetically illustrate how the polyfill works. if (typeof TextEncoder === "undefined") { TextEncoder=function TextEnc...
USBDevice.controlTransferOut() - Web APIs
ng whether the tranfer is "standard" (common to all USB devices) "class" (common to an industry-standard class of devices) or "vendor". recipient: Specifices the target of the transfer on the device, one of "device", "interface", "endpoint", or "other". request: A vendor-specific command. value: Vender-specific request parameters. index: The interface number of the recipient. data A
TypedArray containing the data that will be transfered to the device. Not all commands require data; some commands can send data just through the value parameter. Check with your device to see what the specific request requires. Return value A promise that resolves with a USBOutTransferResult. Specifications Specification Status Comment WebUSBThe definition of 'controlTransferOu...
USBDevice.isochronousTransferOut() - Web APIs
The isochronousTransferOut() method of the USBDevice interface returns a promise that resolves with a USBIsochronousOutTransferResult when time sensitive information has been transmitted to the USB device. Syntax var promise = USBDevice.isochronousTransferOut(endpointNumber, data, packetLengths) Parameters endpointNumber The number of a device-specific endpoint (buffer). data A
TypedArray containing the data to send to the device. packetLengths An array of lengths for the packets being transfered. Return value A promise that resolves with a USBIsochronousOutTransferResult. Specifications Specification Status Comment WebUSBThe definition of 'isochronousTransferOut()' in that specification. Draft Initial definition. ...
USBDevice.transferOut() - Web APIs
The transferOut() method of the USBDevice interface returns a promise that resolves with a USBTransferOutResult when bulk or interrupt data is sent to the USB device. Syntax var promise = USBDevice.transferOut(endpointNumber, data) Parameters endpointNumber The number of a device-specific endpoint (buffer). data A
TypedArray containing the data to send to the device. Return value A promise that resolves with a USBTransferOutResult. Specifications Specification Status Comment WebUSBThe definition of 'transferOut()' in that specification. Draft Initial definition. ...
Iterators and generators - JavaScript
Syntaxes expecting iterables Some statements and expressions expect iterables. For example: the for-of loops, yield*. for (let value of ['a', 'b', 'c']) { console.log(value); } // "a" // "b" // "c" [...'abc']; // ["a", "b", "c"] function* gen() { yield* ['a', 'b', 'c']; } gen().
TypeError: "x" is not a function - JavaScript
n. Maybe there is a typo in the function name? Maybe the object you are calling the method on does not have this function? For example, JavaScript Objects have no map function, but the JavaScript Array object does. There are many built-in functions in need of a (callback) function. ...
TypeError: 'x' is not iterable - JavaScript
The JavaScript exception "is not iterable" occurs when the value which is given as the right hand-side of for...of or as argument of a function such as Promise.all or
TypedArray.from, is not an iterable object. Message TypeError: 'x' is not iterable (Firefox, Chrome) TypeError: 'x' is not a function or its return value is not iterable (Chrome) Error type TypeError What went wrong? The value which is given as the right hand-side of for...of or as argument of a function such as Promise.all or
TypedArray.from, is not an iterable object. An iterable can be a built-in iterable type such as Array, String or Map, a generator result, or an object implementing the iterable protocol. Examples Iterating over Object properties In JavaScript, Objects are not iterable unless they implement the iterabl...
Array.prototype.copyWithin() - JavaScript
end copying elements from. copyWithin copies up to but not including end. If negative, end will be counted from the end. If end is omitted, copyWithin will copy until the last index (default to arr.length). Return value The modified array. Description The copyWithin works like C and C++'s memmove, and is a high-performance method to shift the data of an Array. This especially applies to the
TypedArray method of the same name. The sequence is copied and pasted as one operation; pasted sequence will have the copied values even when the copy and paste region overlap. The copyWithin function is intentionally generic, it does not require that its this value be an Array object. The copyWithin method is a mutable method. It does not alter the length of this, but it will change its content and creat...
Array.isArray() - JavaScript
); // false Array.isArray(undefined); // false Syntax Array.isArray(value) Parameters value The value to be checked. Return value true if the value is an Array; otherwise, false. Description If the value is an Array, true is returned; otherwise, false is. See the article "Determining with absolute accuracy whether or not a JavaScript object is an array" for more details. Given a
TypedArray instance, false is always returned. Polyfill Running the following code before any other code will create Array.isArray() if it's not natively available. if (!Array.isArray) { Array.isArray = function(arg) { return Object.prototype.toString.call(arg) === '[object Array]'; }; } Examples Using Array.isArray // all following calls return true Array.isArray([]); Array.isArray([1]); Ar...
Atomics.isLockFree() - 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 Atomics.isLockFree(size) Parameters size The size in bytes to check. Return value A Boolean indicating whether the operation is lock free. ...
Atomics.load() - JavaScript
The static Atomics.load() method returns a value at a given position 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 Atomics.load(
typedArray, index) Parameters
typedArray An integer typed array. One of Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array. index The position in the
typedArray to load from. Return value The value at the given position (
typedArray[index]). Exceptions Throws a TypeError, if
typedArray is not one of the allowed integer types. Throws a RangeError, if index is out of bounds in the
typedArray. Examples U...
Atomics.notify() - JavaScript
The static Atomics.notify() method notifies up some agents that are sleeping in the wait queue. Note: This operation works with a shared Int32Array only. It will return 0 on non-shared ArrayBuffer objects. Syntax Atomics.notify(
typedArray, index, count) Parameters
typedArray A shared Int32Array. index The position in the
typedArray to wake up on. count Optional The number of sleeping agents to notify. Defaults to +Infinity. Return value Returns the number of woken up agents. Returns 0, if a non-shared ArrayBuffer object is used. Exceptions Throws a TypeError, if
typedArray is not a Int32Array. Throws a RangeError, if index is out of bounds in the
typedArray. Examples Using notify Given a shared Int32Array: const sab = new SharedArrayBuffer(1024); const int32 = new I...
JSON.stringify() - JavaScript
ke no sense in JSON let a = ['foo', 'bar']; a['baz'] = 'quux'; // a: [ 0: 'foo', 1: 'bar', baz: 'quux' ] JSON.stringify(a); // '["foo","bar"]' JSON.stringify({ x: [10, undefined, function(){}, Symbol('')] }); // '{"x":[10,null,null,null]}' // Standard data structures JSON.stringify([new Set([1]), new Map([[1, 2]]), new WeakSet([{a: 1}]), new WeakMap([[{a: 1}, 2]])]); // '[{},{},{},{}]' //
TypedArray JSON.stringify([new Int8Array([1]), new Int16Array([1]), new Int32Array([1])]); // '[{"0":1},{"0":1},{"0":1}]' JSON.stringify([new Uint8Array([1]), new Uint8ClampedArray([1]), new Uint16Array([1]), new Uint32Array([1])]); // '[{"0":1},{"0":1},{"0":1},{"0":1}]' JSON.stringify([new Float32Array([1]), new Float64Array([1])]); // '[{"0":1},{"0":1}]' // toJSON() JSON.stringify({ x: 5, y: 6, toJSON(){...