Node.js util.types.isAnyArrayBuffer() Method

Last Updated : 8 Oct, 2021
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: javascript
// 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: javascript
// 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
Comment

Explore