Node.js util.types.isInt16Array() Method
The util.types.isInt16Array() method is an inbuilt application programming interface of the util module which is used to check type for Int16Array in the node.js.
Syntax:
util.types.isInt16Array( value )
Parameters: This method accepts single parameter as mentioned above and described below.
- value: It is a required parameter that holds any datatype.
Return Value: It returns a boolean value, TRUE if the value is a Int16Array object, FALSE otherwise.
Below examples illustrate the use of util.types.isInt16Array() method in Node.js:
Example 1:
// Node.js program to demonstrate the // util.types.isInt16Array() Method // Allocating util module const util = require( 'util' ); // Value to be passed as parameter of // util.types.isInt16Array() method var v1 = new BigInt64Array(); var v2 = new BigUint64Array(); var v3 = new Float32Array(); var v4 = new Int8Array(); var v5 = new Int16Array(); // Printing the returned value from // util.types.isInt16Array() method console.log(util.types.isInt16Array(v1)); console.log(util.types.isInt16Array(v2)); console.log(util.types.isInt16Array(v3)); console.log(util.types.isInt16Array(v4)); console.log(util.types.isInt16Array(v5)); |
Output:
false false false false true
Example 2:
// Node.js program to demonstrate the // util.types.isInt16Array() Method // Allocating util module const util = require( 'util' ); // Value to be passed as parameter of // util.types.isInt16Array() method var v1 = new Int8Array(); var v2 = new Int16Array(); // Calling util.types.isInt16Array() method if (util.types.isInt16Array(v1)) console.log( "The passed value is a Int16Array." ); else console.log( "The passed value is not a Int16Array" ); if (util.types.isInt16Array(v2)) console.log( "The passed value is a Int16Array." ); else console.log( "The passed value is not a Int16Array" ); |
Output:
The passed value is not a Int16Array. The passed value is a Int16Array
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_isint16array_value
Please Login to comment...