TypedArray.BYTES_PER_ELEMENT property in JavaScript


The BYTES_PER_ELEMENT property of the Typed Array represents the number of bytes in each element in it.

Syntax

Its Syntax is as follows

Float32Array.BYTES_PER_ELEMENT;

Example

 Live Demo

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var sizeOfFloat64Array = Float32Array.BYTES_PER_ELEMENT;
      document.write("Size of the float 32 array: "+sizeOfFloat64Array);
      document.write("<br>");
      var sizeOfInt16Array = Int16Array.BYTES_PER_ELEMENT;
      document.write("Size of the int 16 array: "+sizeOfInt16Array);
   </script>
</body>
</html>

Output

Size of the float 32 array: 4
Size of the int 16 array: 2

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 25-Jun-2020

60 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements