Node.js – util.types.isUint16Array() Method


The util.types.isUint16Array() method checks whether the passed value is a builtin Uint16Array instance or not. If the above condition is satisfied, it returns True, else False.

Syntax

util.types.isUint16Array(value)

Parameters

It takes a single parameter −

  • value − This input value takes input for the required parameter and checks if it's a Uint16Array instance or not.

It returns True or False based upon the input value passed.

Example 1

Create a file with the name "isUint16Array.js" and copy the following code snippet. After creating the file, use the command "node isUint16Array.js" to run this code.

// util.types.isUint16Array() Demo Example

// Importing the util module
const util = require('util');

// Passing normal Array as input value
console.log("1." + util.types.isUint16Array(new ArrayBuffer()));

// Passing a Uint16 array as input
console.log("2." + util.types.isUint16Array(new Uint16Array()));

// Passing a Float64 array as input
console.log("3." + util.types.isUint16Array(new Float64Array()));

Output

C:\home
ode>> node isUint16Array.js 1.false 2.true 3.false

Example 2

Let’s have a look at one more example

// util.types.isUint16Array() Demo Example

// Importing the util module
const util = require('util');

// Initialising the Uint16Array with values
var arr = new Uint16Array([1, 5, 8, 1, 95]);

// Passing Uint16 Array with values as input
console.log("1." + util.types.isUint16Array(arr));

// Passing a Uint16 array 0th value as input
console.log("2." + util.types.isUint16Array(arr[0]));

Output

C:\home
ode>> node isBigInt64Array.js 1.true 2.false

Updated on: 18-Aug-2021

29 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements