The TypedArray.prototype property represents the prototype for TypedArray constructors.
Property attributes of TypedArray.prototype |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Description
TypedArray instances inherit from TypedArray.prototype. You can use the constructor's prototype object to add properties or methods to all TypedArray instances, where TypedArray is one of the typed array types.
See also the description about TypedArray for more information about inheritance.
Properties
TypedArray.prototype.constructor- Returns the function that created an instance's prototype. This is one the corresponding typed array type functions by default.
TypedArray.prototype.bufferRead only- Returns the
ArrayBufferreferenced by the typed array. Fixed at construction time and thus read only. TypedArray.prototype.byteLengthRead only- Returns the length (in bytes) of the typed array from the start of its
ArrayBuffer. Fixed at construction time and thus read only. TypedArray.prototype.byteOffsetRead only- Returns the offset (in bytes) of the typed array from the start of its
ArrayBuffer. Fixed at construction time and thus read only. TypedArray.prototype.lengthRead only- Returns the number of elements hold in the typed array. Fixed at construction time and thus read only.
Methods
TypedArray.prototype.copyWithin()- Copies a sequence of array elements within the array. See also
Array.prototype.copyWithin(). TypedArray.prototype.entries()- Returns a new
Array Iteratorobject that contains the key/value pairs for each index in the array. See alsoArray.prototype.entries(). TypedArray.prototype.every()- Tests whether all elements in the array pass the test provided by a function. See also
Array.prototype.every(). TypedArray.prototype.fill()- Fills all the elements of an array from a start index to an end index with a static value. See also
Array.prototype.fill(). TypedArray.prototype.filter()- Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also
Array.prototype.filter(). TypedArray.prototype.find()- Returns the found value in the array, if an element in the array satisfies the provided testing function or
undefinedif not found. See alsoArray.prototype.find(). TypedArray.prototype.findIndex()- Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also
Array.prototype.findIndex(). TypedArray.prototype.forEach()- Calls a function for each element in the array. See also
Array.prototype.forEach(). TypedArray.prototype.includes()- Determines whether a typed array includes a certain element, returning
trueorfalseas appropriate. See alsoArray.prototype.includes(). TypedArray.prototype.indexOf()- Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also
Array.prototype.indexOf(). TypedArray.prototype.join()- Joins all elements of an array into a string. See also
Array.prototype.join(). TypedArray.prototype.keys()- Returns a new
Array Iteratorthat contains the keys for each index in the array. See alsoArray.prototype.keys(). TypedArray.prototype.lastIndexOf()- Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also
Array.prototype.lastIndexOf(). TypedArray.prototype.map()- Creates a new array with the results of calling a provided function on every element in this array. See also
Array.prototype.map(). TypedArray.prototype.move()Unimplemented- Former non-standard version of
TypedArray.prototype.copyWithin(). TypedArray.prototype.reduce()- Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also
Array.prototype.reduce(). TypedArray.prototype.reduceRight()- Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also
Array.prototype.reduceRight(). TypedArray.prototype.reverse()- Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also
Array.prototype.reverse(). TypedArray.prototype.set()- Stores multiple values in the typed array, reading input values from a specified array.
TypedArray.prototype.slice()- Extracts a section of an array and returns a new array. See also
Array.prototype.slice(). TypedArray.prototype.some()- Returns true if at least one element in this array satisfies the provided testing function. See also
Array.prototype.some(). TypedArray.prototype.sort()- Sorts the elements of an array in place and returns the array. See also
Array.prototype.sort(). TypedArray.prototype.subarray()- Returns a new TypedArray from the given start and end element index.
TypedArray.prototype.values()- Returns a new
Array Iteratorobject that contains the values for each index in the array. See alsoArray.prototype.values(). TypedArray.prototype.toLocaleString()- Returns a localized string representing the array and its elements. See also
Array.prototype.toLocaleString(). TypedArray.prototype.toString()- Returns a string representing the array and its elements. See also
Array.prototype.toString(). TypedArray.prototype[@@iterator]()- Returns a new
Array Iteratorobject that contains the values for each index in the array.
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'TypedArray prototype' in that specification. |
Standard | Initial definition. |
| ECMAScript 2017 Draft (ECMA-262) The definition of 'TypedArray prototype' in that specification. |
Draft |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 7.0 | 4.0 (2) | 10 | 11.6 | 5.1 |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | 4.0 | (Yes) | 4.0 (2) | 10 | 11.6 | 4.2 |