Open In App

Lodash _.isTypedArray() Method

Last Updated : 03 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
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.

Reference: https://lodash.com/docs/4.17.15#isTypedArray


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads