📜  JavaScript TypedArray

📅  最后修改于: 2020-10-25 04:38:25             🧑  作者: Mango

JavaScript TypedArray

JavaScript TypedArray对象说明了基础二进制数据缓冲区的类似数组的视图。有许多不同的全局属性,其值是特定元素类型的TypedArray构造函数,如下所示。

TypedArray的类型

Int8Array

  • 字节大小: 1
  • 说明: 8位二进制补码带符号整数。
  • 类型:字节。
  • 值范围: -128至127

Unit8Array

  • 字节大小: 1
  • 说明: 8位二进制补码签名八位字节。
  • 类型:八位位组。
  • 值范围: 0到255。

Unit8ClampedArray

  • 字节大小: 1
  • 说明: 8位无符号整数(固定的)八位字节。
  • 类型:八位位组。
  • 值范围: 0到255。

Int16Array

  • 字节大小: 2
  • 说明: 16位二进制补码有符号整数。
  • 类型:短。
  • 值范围: -32768至32767。

Unit16Array

  • 字节大小: 2
  • 说明: 16位无符号整数。
  • 类型:无符号短。
  • 值范围: 0到65535。

Int32Array

  • 字节大小: 4
  • 说明: 32位二进制补码有符号整数。
  • 类型:长。
  • 值范围: -2147483648至2147483647。

Uint32Array

  • 字节大小: 4
  • 说明: 32位无符号整数。
  • 类型:无符号长。
  • 值范围: 0至4294967295

Float32Array

  • 字节大小: 4
  • 说明: 32位IEEE浮点数不受限制的浮点数。
  • 类型:不受限制的浮点数。
  • 值范围: 1.2×10 -38至3.4×10 38

Float64Array

  • 字节大小: 8
  • 说明: 64位IEEE浮点数不受限制。
  • 类型:无限制的双精度型。
  • 值范围: 5.0×10-324至1.8×10308

JavaScript TypedArray方法

让我们看一下JavaScript TypedArray方法的列表及其说明。

Methods Description
copyWithin() The copyWithin () method copies a portion of an array to another location in the same array and returns the size without modification.
entries() The JavaScript entries() method returns a new Array Iterator object that contains key/value pairs for each index in the array.
every() javaScript Array.every() method test whether all the elements of the array satisfy the given condition or not.
fill() The javaScript fill() method is used to fill all the elements of array from a start index to an end index with a static value.
Filter() The JavaScript Array filter() method form a new array that fall under a given criteria from an existing array.
find() The JavaScript find() Method is used to get the value of the first element in the array that satisfies the provided condition.
findIndex() The JavaScript findIndex() method is provide the index of the element that complete the given test in the array.
forEach() The JavaScript forEach() method calls the provided function once for each element of the array.
includes() The JavaScript Array includes() method is inbuilt function in JavaScript which is used to determines whether a particular element is present in the array or not.
indexof() The JavaScript indexof() Method is used to find the index of the element provided as the argument to the function.
join() The JavaScript join() method is used to join all elements of an Array into a string.
Keys() The JavaScript Keys() method is an inbuilt function in JavaScript. This method returns an Array Iterator object with the keys of an array.
lastIndexof() The javaScript lastIndex()of method returns the last position of a value, or it return -1 if the value is not found.
map() The JavaScript map() method form a new array with the result of calling a function for every element.
reduce() The JavaScript reduce() method reduce the elements of an array into a single value.
reduceRight() The JavaScript reduceRight() method reduce the elements of an array into a single value.
reverse() The JavaScript reverse() method is used to reverse the array.
set() The JavaScript set() method is used to store values into the given array.
Slice() The JavaScript slice() method gives the selected elements of the array on which is implemented.
some() JavaScript some() method examine the elements of the array that satisfies the given condition or not.
sort() The JavaScript sort() method is used to sort the array and returns the updated array.
subarray() The JavaScript subarray() method returns a new array and it does not change the original array.
values() The JavaScript values() method is used to define the value of the contents in the array
toLocaleString() The JavaScript toLocaleString() method is used to convert the element of the given array into a string.
toString() The JavaScript 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 “,”.