Node.js util.types.isTypedArray() Method
Last Updated :
13 Oct, 2021
The util.types.isTypedArray() method is an inbuilt application programming interface of util module which is primarily designed to support the needs of Node.js own internal APIs.
The util.types.isTypedArray() method is used to determine whether the value is a built-in TypedArray instance.
Syntax:
util.types.isTypedArray( value )
Parameter: This method accepts a single parameters value which holds any valid JavaScript data types like Boolean, Null, Number, Object, etc.
Return value: It returns a Boolean value i.e. returns true if value is a built-in TypedArray instance otherwise it returns false.
Below examples illustrate the use of util.types.isTypedArray() method in Node.js:
Example 1:
const util = require( 'util' );
console.log(util.types.isTypedArray( new ArrayBuffer()));
console.log(util.types.isTypedArray( new Uint8Array()));
console.log(util.types.isTypedArray( new Float64Array()));
|
Output:
false
true
true
Example 2:
const util = require( 'util' );
console.log(util.types.isTypedArray([1, 5, 8, 18]));
console.log(util.types.isTypedArray( new Int8Array(8)));
|
Output:
false
true
Note: The above program will compile and run by using the node index.js
command.
Reference: https://nodejs.org/dist/latest-v13.x/docs/api/util.html#util_util_types_istypedarray_value
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...