JavaScript typedArray.length() Method
Last Updated :
10 Feb, 2023
The typedArray.length is an inbuilt property in JavaScript which is used to return the length of the given typedArray.
Syntax:
typedArray.length
Parameters: It does not accept any parameter because it is a property not a function. Return value: It returns the length of the given typedArray.
Example 1:
javascript
var A = new Uint8Array([5, 10, 15, 15, 5, 20, 10]);
var B = new Uint8Array([5, 10]);
var C = new Uint8Array([5, 10, 15]);
var D = new Uint8Array([5, 10, 15, 15, 5]);
var E = new Uint8Array([5, 10, 15, 15, 5, 20]);
b = A.length
c = B.length
d = C.length
e = D.length
f = E.length
console.log(b);
console.log(c);
console.log(d);
console.log(e);
console.log(f);
|
Output:
7
2
3
5
6
Example 2:
javascript
const A = new ArrayBuffer(8);
const B = new ArrayBuffer(6);
const C = new ArrayBuffer(16);
const D = new ArrayBuffer(32);
const E = new Uint8Array(A);
const F = new Uint8Array(B);
const G = new Uint8Array(C);
const H = new Uint8Array(D);
a = E.length
b = F.length
c = G.length
d = H.length
console.log(a);
console.log(b);
console.log(c);
console.log(d);
|
Output:
8
6
16
32
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...