Related Articles

Related Articles

JavaScript | typedArray.BYTES_PER_ELEMENT with Examples
  • Last Updated : 03 Aug, 2018

The typedArray.BYTES_PER_ELEMENT is an inbuilt property in JavaScript which is used to return the size in bytes of the each element in an given typedArray.
Syntax:

typedArray.BYTES_PER_ELEMENT;

Parameter: It does not accept any parameter because it is a property not a function.

Return value: It returns the size in bytes of the each element in an given tyepedArray.
JavaScript code to show the working of this function:

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
  
    // Calling BYTES_PER_ELEMENT on some typedArray
    a = Int8Array.BYTES_PER_ELEMENT;
    b = Uint8Array.BYTES_PER_ELEMENT;
    c = Uint8ClampedArray.BYTES_PER_ELEMENT;
    d = Int16Array.BYTES_PER_ELEMENT;
    e = Uint16Array.BYTES_PER_ELEMENT;
    f = Int32Array.BYTES_PER_ELEMENT;
    g = Uint32Array.BYTES_PER_ELEMENT;
    h = Float32Array.BYTES_PER_ELEMENT;
    i = Float64Array.BYTES_PER_ELEMENT;
  
   // Printing the size in bytes of the
   // each element in 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:

1
1
1
2
2
4
4
4
8

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :