Open In App

Lodash _.isTypedArray() Method

Last Updated : 04 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Lodash _.isTypedArray() method is used to find whether the given value is a typed array or not. It returns True if the given value is a typed array. Otherwise, it returns false.

Syntax:

_.isTypedArray(value);

Parameters:

  • value: This parameter holds the value to check.

Return Value:

  • This method returns true if the value is a typed array, else false.

Example 1: In this example, we are getting false as an output because the given value is not a typed array.

javascript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.isTypedArray() method  
// Passing a array as an argument
console.log(_.isTypedArray([]));

// Passing an array with value as an argument
console.log(_.isTypedArray([1, 2, 3, 4]));

Output:

false
false

Example 2: In this example, we are getting true as an output because the given value is a typed array.

javascript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.isTypedArray() method  
// Passing a array as an argument
console.log(_.isTypedArray(new Int8Array(8)));

// Passing a typedArray objects Float64Array
console.log(_.isTypedArray(new Float64Array()));

Output:

true
true

Note: This will not work in normal JavaScript because it requires the library lodash to be installed.


Next Article

Similar Reads