Node.js | util.types.isInt32Array() Method

The util.types.isInt32Array() method of util module is primarily designed to support the needs of Node.js own Internal APIs. It is used to check whether the passed instance in the method is a built-in Int32Array instance or not.

Syntax:

util.types.isInt32Array( value )

Parameters: This method accepts a single parameter value which holds any value i.e instance of any module.



Return value: This method returns a Boolean value i.e true if the passed value is instance of Int32Array otherwise returns false.

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

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the   
// util.types.isInt32Array() method
  
// It includes util module
const util = require('util');
  
// Return false as passed instance is of map
console.log(util.types.isInt32Array(new Map()));
  
// Return true as passed instance is of Int32Array
console.log(util.types.isInt32Array(new Int32Array()));

chevron_right


Output:

false
true

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the   
// util.types.isInt32Array() method
  
// It includes util module
const util = require('util');
  
// Making an instance of Int32Array
// of size 2
var array1 = new Int32Array(2);
  
// Intializing the zeroth element 
array1[0] = 42;
  
// Returns true as passed instance is of Int32Array
console.log(util.types.isInt32Array(array1));
   
// Making an instance of Int32Array
var array2 = new Int32Array([21, 31]);
  
// Returns true as passed instance is of Int32Array
console.log(util.types.isInt32Array(array2));
  
// Making an instance of Int32Array
var array3 = new Int32Array([21, 31]);
  
// Making another instance of Int32Array by
// passing an instance of Int32Array
var array4 = new Int32Array(array3);
  
// Returns true as passed instance is of Int32Array
console.log(util.types.isInt32Array(array4));
  
// Making an instance of Int16Array of size 2
var array5 = new Int16Array(2);
  
// Intializing the zeroth element 
array5[0] = 10;
  
// Returns false as passed instance is of Int16Array
console.log(util.types.isInt32Array(array5));

chevron_right


Output:

true
true
true
false

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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.