JavaScript arrayBuffer.byteLength Property
Last Updated :
17 Jul, 2023
The Javascript arrayBuffer.byteLength is a property in JavaScript that gives the length of an arrayBuffer in bytes.
Syntax:
ArrayBuffer.byteLength
Parameters: It does not accept any parameter because arrayBuffer.byteLength is a property, not a function.
Return Value: It returns the length of an arrayBuffer in bytes.
JavaScript code to show the working of the arrayBuffer.byteLength property:
Example: This is a basic example showing the usage of arrayBuffer.byteLength property.
javascript
let A = new ArrayBuffer(5);
let bytes1 = A.byteLength;
console.log(bytes1);
|
Errors and Exceptions:
If the length of arrayBuffer is given in fractions, it returns length in the whole number and when the length is given in the form of string then it returns a length of zero (0).
Example 1: In this example, we will pass the length of arrayBuffer in fractions.
javascript
let A = new ArrayBuffer(5.6);
let bytes1 = A.byteLength;
console.log(bytes1);
|
Example 2: In this example, we will pass the length of arrayBuffer in string format.
javascript
let A = new ArrayBuffer( "a" );
let bytes1 = A.byteLength;
console.log(bytes1);
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...