Node.js util.types.isFloat32Array() Method

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

Syntax:

util.types.isFloat32Array( value )

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

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

Return: This returns a boolean value, TRUE if the value is a Float32Array, FALSE otherwise. 

The below examples illustrate the use of util.types.isFloat32Array() method in Node.js: 

Example 1: 

javascript




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


Output:

false
false
true
false
false

Example 2: 

javascript




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


Output:

The passed value is a Float32Array.
The passed value is not a Float32Array

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_isfloat32array_value