JavaScript | typedArray.@@species with Example
The typedArray.@@species is an inbuilt property in JavaScript which is used to return the constructor of the given typedArray.
The typedArray is of many types like-
- Int8Array
- Uint8Array
- Uint8ClampedArray
- Int16Array
- Uint16Array
- Int32Array
- Uint32Array
- Float32Array
- Float64Array
Syntax:
typedArray[Symbol.species]
Parameters: It does not accept any parameter because it is a property not a function.
Return value: It returns the constructor of the given typedArray.
JavaScript code to show the working of this property:
<script> // Calling species property on different typedArray a = Int8Array[Symbol.species]; b = Uint8Array[Symbol.species]; c = Uint8ClampedArray[Symbol.species]; d = Int16Array[Symbol.species]; e = Uint16Array[Symbol.species]; f = Int32Array[Symbol.species]; g = Uint32Array[Symbol.species]; h = Float32Array[Symbol.species]; i = Float64Array[Symbol.species]; // Printing the constructor of the given typedArray document.write(a + "<br>" ); document.write(b + "<br>" ); document.write(c + "<br>" ); document.write(d + "<br>" ); document.write(e + "<br>" ); document.write(f + "<br>" ); document.write(g + "<br>" ); document.write(h + "<br>" ); document.write(i); </script> |
chevron_right
filter_none
Output:
function Int8Array() { [native code] } function Uint8Array() { [native code] } function Uint8ClampedArray() { [native code] } function Int16Array() { [native code] } function Uint16Array() { [native code] } function Int32Array() { [native code] } function Uint32Array() { [native code] } function Float32Array() { [native code] } function Float64Array() { [native code] }