Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Node.js util.types.isInt8Array() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The util.types.isInt8Array() method is an inbuilt application programming interface of the util module which is used to type check for Int8Array in the node.js. 

Syntax:

util.types.isInt8Array( value )

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

  • value: It is a required parameter that holds any data type.

Return Value: It returns a boolean value, TRUE if the value is an Int8Array object, FALSE otherwise. 

Example 1: The below example illustrates the use of util.types.isInt8Array() method in Node.js

javascript




// Node.js program to demonstrate the
// util.types.isInt8Array() Method
 
// Allocating util module
const util = require('util');
 
// Value to be passed as parameter of
// util.types.isInt8Array() method
let v1 = new BigInt64Array();
let v2 = new BigUint64Array();
let v3 = new Float32Array();
let v4 = new ArrayBuffer();
let v5 = new Int8Array();
 
// Printing the returned value from
// util.types.isInt8Array() method
console.log(util.types.isInt8Array(v1));
console.log(util.types.isInt8Array(v2));
console.log(util.types.isInt8Array(v3));
console.log(util.types.isInt8Array(v4));
console.log(util.types.isInt8Array(v5));

Output:

false
false
false
false
true

Example 2: In this example, we illustrate the use of util.types.isInt8Array() method in Node.js

javascript




// Node.js program to demonstrate the
// util.types.isInt8Array() Method
 
// Allocating util module
const util = require('util');
 
// Value to be passed as parameter of
// util.types.isInt8Array() method
let v1 = new Int8Array();
let v2 = new Int16Array();
 
// Calling util.types.isInt8Array() method
if (util.types.isInt8Array(v1))
    console.log("The passed value is a Int8Array.");
else
    console.log("The passed value is not a Int8Array");
 
if (util.types.isInt8Array(v2))
    console.log("The passed value is a Int8Array.");
else
    console.log("The passed value is not a Int8Array");

Output:

The passed value is a Int8Array.
The passed value is not a Int8Array

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_isint8array_value


My Personal Notes arrow_drop_up
Last Updated : 31 Mar, 2023
Like Article
Save Article
Similar Reads
Related Tutorials