Available in Chrome 45+ | View on GitHub | Browse Samples
ECMAScript 2015
specification adds additional static methods on TypedArray
subclasses (Int8Array
, Float32Array
, ...) and instance
methods on their prototype that mirror most Array.prototype
methods.
The TypedArray.from()
method creates a new way to make
TypedArrays
based on existing iterable or Array-like objects,
analogous to Array.from
.
Uint8Array.from(new Set([1, 1, 2, 3])); // [1, 2, 3]
Uint8Array.from('hello'); // [0, 0, 0, 0, 0]
Uint8Array.from('hello', x => x.charCodeAt(0)); // [104, 101, 108, 108, 111]
The TypedArray.of()
method is almost the same as Array.of()
.
Uint8Array.of(1, 2, 3, 256 + 4); // [1, 2, 3, 4]
Array.prototype
instance methodsTypedArray.prototype.copyWithin
TypedArray.prototype.every
TypedArray.prototype.fill
TypedArray.prototype.filter
TypedArray.prototype.find
TypedArray.prototype.findIndex
TypedArray.prototype.forEach
TypedArray.prototype.indexOf
TypedArray.prototype.join
TypedArray.prototype.lastIndexOf
TypedArray.prototype.map
TypedArray.prototype.reduce
TypedArray.prototype.reduceRight
TypedArray.prototype.reverse
TypedArray.prototype.some
TypedArray.prototype.sort
TypedArray.prototype.toLocaleString
TypedArray.prototype.toString