Open In App

Node.js Buffer.buffer Property

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The Buffer.buffer property is an inbuilt application programming interface of class Buffer within buffer module which is used to get the object of array buffer equivalent to this buffer object.

Syntax:

const buf.buffer

Return Value: This property returns the object of array buffer.

Example 1: Filename: index.js

Javascript




// Node.js program to demonstrate the
// Buffer.buffer property
  
// Creating a Buffer
const buff = Buffer.from([1, 2, 3, 4, 5]);
  
// Getting the value of array buffer
const value = buff.buffer;
  
// Display the result
console.log("Big Integer :- " + value);


Output:

Big Integer :- [object ArrayBuffer]

Example 2: Filename: index.js

Javascript




// Node.js program to demonstrate the
// Buffer.buffer property
  
// Creating and initializing arraybuffer object
const arrbuff = new ArrayBuffer(16);
  
// Getting buffer object form existing 
// arraybuffer object
const buffer = Buffer.from(arrbuff);
  
// Display the result
if(buffer.buffer === arrbuff)
    console.log("both buffer is equivalent");
else
    console.log("both buffer is not equivalent");


Output:

both buffer is equivalent

Run the index.js file using the following command:

node index.js

Reference: https://nodejs.org/api/buffer.html#buffer_buf_buffer


Last Updated : 07 Aug, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads