Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript ArrayBuffer Complete Reference

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 17 Jan, 2023
Improve Article
Save Article

ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. The contents of an ArrayBuffer cannot be directly manipulated and can only be accessed through a DataView Object or one of the typed array objects. These Objects are used to read and write the contents of the buffer. 

syntax

Javascript




const buffer = new ArrayBuffer(8); // Create a New ArrayBuffer Object
console.log(buffer);

Output

ArrayBuffer {
  [Uint8Contents]: <00 00 00 00 00 00 00 00>,
  byteLength: 8
}

Javascript




const buffer = new ArrayBuffer(8);
const view = new Int32Array(buffer);
console.log(view);

Output

Int32Array(2) [ 0, 0 ]

Example: The arrayBuffer.isView() property of Javascript.

Javascript




// Creation of ArrayBuffer having a size in bytes
var buffer = new ArrayBuffer(12);
 
// Use of ArrayBuffer.isView function
A = ArrayBuffer.isView(new Int32Array())
console.log(A);

Output

true

The complete list of JavaScript ArrayBuffer is listed below:

JavaScript ArrayBuffer Methods:

Methods

Description

isView() It checks given an argument for the function is a typed array or not.
slice()Selections from a given start to a (not all-inclusive) given end.

JavaScript ArrayBuffer Properties:

properties

Description

byteLength It is used to represent fixed-length binary data
[@@species]Constructs array buffer methods return values 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!