Open In App

Node.js util.types.isAnyArrayBuffer() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The util.types.isAnyArrayBuffer() method is an inbuilt application programming interface of the util module which is used to perform type checking for any built-in ArrayBuffer objects in the node.js.

Syntax:

util.types.isAnyArrayBuffer( value )

Parameters: This method accepts single parameter as mentioned above and described below:

  • value: It is a required parameter of any datatype.

Return Value: It returns a boolean value i.e. TRUE if the value is a built-in SharedArrayBuffer or ArrayBuffer object, FALSE otherwise.

Below examples illustrate the use of util.types.isAnyArrayBuffer() method in Node.js:

Example 1:




// Node.js program to demonstrate the   
// util.types.isAnyArrayBuffer() Method 
  
// Allocating util module
const util = require('util');
  
// Printing the returned value from
// util.types.isAnyArrayBuffer() method
console.log(util.types.isAnyArrayBuffer(new ArrayBuffer()));
console.log(util.types.isAnyArrayBuffer(new SharedArrayBuffer()));
console.log(util.types.isAnyArrayBuffer(12));
console.log(util.types.isAnyArrayBuffer("geeksforgeeks"));


Output:

true
true
false
false

Example 2:




// Node.js program to demonstrate the   
// util.types.isAnyArrayBuffer() Method 
  
// Allocating util module
const util = require('util');
  
// Printing the returned value from 
// util.types.isAnyArrayBuffer() method
if (util.types.isAnyArrayBuffer(new ArrayBuffer())) {
    console.log("Passed value is either built in "
        + "ArrayBuffer or SharedArrayBuffer ");
}
if (util.types.isAnyArrayBuffer(new SharedArrayBuffer())) {
    console.log("Passed value is either built in "
        + "ArrayBuffer or SharedArrayBuffer ");
}


Output:

Passed value is either built in ArrayBuffer or SharedArrayBuffer
Passed value is either built in ArrayBuffer or SharedArrayBuffer

Note: The above program will compile and run by using the node filename.js command.

Reference: https://nodejs.org/api/util.html#util_util_types_isanyarraybuffer_value



Last Updated : 08 Oct, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads