Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js – util.types.isInt32Array() Method
The util.types.isInt32Array() method checks whether the passed value is a built-in Int32Array instance or not. If the above condition is satisfied, it returns True, else False.
Syntax
util.types.isInt32Array(value)
Parameters
value − This input takes input for the required parameter and checks if it's an Int32Array instance or not. Returns True or False based upon the input value passed.
Example 1
Create a file with name isInt32Array.js and copy the below code snippet.
After creating the file, use the following command to run this code and check the output -
node isInt32Array.js
Program Code
// util.types.isInt32Array() Demo Example
// Importing the util module
const util = require('util');
// Passing normal Int32-Array as input value
console.log("1." + util.types.isInt32Array(new Int32Array()));
// Passing a Array buffer as input
console.log("2." + util.types.isInt32Array(new ArrayBuffer()));
// Passing a Float64 array as input
console.log("3." + util.types.isInt32Array(new Int16Array()));
Output
C:\home
ode>> node isInt32Array.js 1.true 2.false 3.false
Example 2
// util.types.isInt32Array() Demo Example
// Importing the util module
const util = require('util');
// Defining int32 array in multiple ways
var int32 = new Int32Array(2);
int32[0] = 42;
var arr = new Int32Array([21,31]);
console.log(arr[1]);
// From an ArrayBuffer
var buffer = new ArrayBuffer(32);
var z = new Int32Array(buffer, 0, 4);
// From an iterable
var iterable = function*(){ yield* [1,2,3]; }();
var arr1 = new Int32Array(iterable);
// Passing int32 Array with values as input
console.log("1." + util.types.isInt32Array(int32));
// Passing a int32 array 0th value as input
console.log("2." + util.types.isInt32Array(arr));
// Passing a int32 array defined by array buffer
console.log("3." + util.types.isInt32Array(z));
// Passing a int32 array defined by iterable
console.log("4." + util.types.isInt32Array(arr1));
Output
C:\home
ode>> node isInt32Array.js 31 1.true 2.true 3.true 4.true
Advertisements