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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<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


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] }


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.