JavaScript – Typed Array


What is a typed array ?

Typed array is an ArrayBufferView that interprets the bytes present in the ArrayBuffer as array of numbers.


This also allows the read and write access to the elements of the array.

What is a typed array in javascript ?

Typed arrays are like objects also provides accessing raw binary data.

These Array objects can also have javascript values assigned dynamically.

JavaScript engines perform optimizations so that these arrays are fast.

This is most useful in manipulating raw binary data into typed arrays.

Javascript advanced course !!!

Click to Learn More about – Javascript online learning

Here is some of the types of Typed Arrays,

SnoTyped ArrayValue RangeSize in BytesDescriptionWeb IDL Type
1Int8Array-128 to 12718-bit two’s complement signed integerbyte
2Uint8Array0 to 25518-bit unsigned integeroctet
3Uint8ClampedArray0 to 25518-bit unsigned integer (clamped)octet
4Int16Array-32768 to 32767216-bit two’s complement signed integershort
5Uint16Array0 to 65535216-bit unsigned integer unsignedshort
6Int32Array-2147483648 to 2147483647432-bit two’s complement signed integerlong
7Uint32Array0 to 4294967295432-bit unsigned integer unsignedlong
8Float32Array1.2×10-38 to 3.4×1038432-bit IEEE floating point number ( 7 significant digits e.g. 1.1234567)unrestricted float
9Float64Array5.0×10-324 to 1.8×10308864-bit IEEE floating point number (16 significant digits e.g. 1.123…15)unrestricted float
10BigInt64Array-263 to 263-1864-bit two’s complement signed integerbigint
11BigUint64Array0 to 264-1864-bit unsigned integerbigint

Typed array methods in Javascript

Here is some of the Methods in Typed Arrays,

SnoMethodsDescription
1copyWithin()copyWithin () method copies a portion of an array to another location in the same array and returns the size without modification.
2entries()entries() method returns a new Array Iterator object that contains key/value pairs for each index in the array.
3every()every() method tests whether all the elements of the array satisfy the given condition or not.
4fill()fill() method is used to fill all the elements of array from a start index to an end index with a static value.
5filter()filter() method forms a new array that falls under a given criteria from an existing array.
6find()find() Method is used to get the value of the first element in the array that satisfies the provided condition.
7findIndex()findIndex() method is used to provide the index of the element that complete the given test in the array.
8forEach()forEach() method calls the provided function once for each element of the array.
9includes()includes() method is used to determine whether a particular element is present in the array or not.
10indexof()indexof() Method is used to find the index of the element provided as the argument to the function.
11join()join() method is used to join all elements of an Array into a string.
12Keys()Keys() method is used to return an Array Iterator object with the keys of an array.
13lastIndexof()lastIndexof() method returns the last position of a value, or it return -1 if the value is not found.
14map()map() method forms a new array with the result of calling a function for every element.
15reduce()reduce() method reduces the elements of an array into a single value.
16reduceRight()reduceRight() method reduces the elements of an array into a single value.
17reverse()reverse() method is used to reverse the array.
18set()set() method is used to store values into the given array.
19Slice()slice() method gives the selected elements of the array on which is implemented.
20some()some() method examines the elements of the array that satisfies the given condition or not.
21sort()sort() method is used to sort the array and return the updated array.
22subarray()subarray() method returns a new array and it does not change the original array.
23values()values() method is used to define the value of the contents in the array
24toLocaleString()toLocaleString() method is used to convert the element of the given array into a string.
25toString()toString() method is used to convert the element of the given array into a string. And these Strings are separated by such as a comma “,”.