JavaScript | typedArray.BYTES_PER_ELEMENT with Examples
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:
<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> |
Output:
1 1 1 2 2 4 4 4 8
Please Login to comment...