JavaScript typedArray.byteOffset Property
Last Updated :
15 Feb, 2023
The typedArray.byteOffset is an inbuilt property in JavaScript that is used to return the offset in bytes of a given typedArray from the start of its ArrayBuffer.
Syntax:
typedArray.byteOffset
Parameter: It does not accept any parameter because it is a property, not a function.
Return value: It returns the offset in bytes of a given typedArray from the start of its ArrayBuffer.
Example:
javascript
var buffer1 = new ArrayBuffer(2);
var buffer2 = new ArrayBuffer(8);
var buffer3 = new ArrayBuffer(16);
var buffer4 = new ArrayBuffer(32);
var A = new Uint8Array(buffer1);
var B = new Uint8Array(buffer2, 4);
var C = new Uint8Array(buffer3, 5);
var D = new Uint8Array(buffer4, 8);
a = A.byteOffset;
b = B.byteOffset;
c = C.byteOffset;
d = D.byteOffset;
console.log(a);
console.log(b);
console.log(c);
console.log(d);
|
Output:
0
4
5
8
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...