Wednesday, February 4, 2026
HomeLanguagesJavascriptJavaScript typedArray.buffer() and typedArray.byteLength() with Example

JavaScript typedArray.buffer() and typedArray.byteLength() with Example

The Javascript typedArray.buffer() is a property in JavaScript which represents the ArrayBuffer referenced by a typedArray and the property typedArray.byteLength() represents the length of the typedArray in bytes. 
Syntax:

typedArray.buffer
typedarray.byteLength

Parameters: It does not accept any parameter because it is a property, not a function. 

Return values: It doesn’t return any value.

JavaScript examples to show the working of this property: 

Example 1: In this example we will see the basic use of the JavaScript typedArray.buffer() and typedArray.byteLength() property in Javascript.

javascript




<script>
    // creating some ArrayBuffers with a size in bytes
    const buffer1 = new ArrayBuffer(8);
    const buffer2 = new ArrayBuffer(12);
    const buffer3 = new ArrayBuffer(20);
    const buffer4 = new ArrayBuffer(22);
    const buffer5 = new ArrayBuffer(4);
      
    // Creating typedArray object for above buffers
    const A = new Uint16Array(buffer1);
    const B = new Uint16Array(buffer2);
    const C = new Uint16Array(buffer3);
    const D = new Uint16Array(buffer4);
    const E = new Uint16Array(buffer5);
      
    // Getting the length of the arrayBuffer
    console.log(A.byteLength);
    console.log(B.byteLength);
    console.log(C.byteLength);
    console.log(D.byteLength);
    console.log(E.byteLength);
</script>


Output:

8
12
20
22
4
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32478 POSTS0 COMMENTS
Milvus
125 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11980 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12066 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6935 POSTS0 COMMENTS
Umr Jansen
6919 POSTS0 COMMENTS