Lodash _.isTypedArray() Method
Last Updated :
03 Nov, 2023
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
const _ = require( "lodash" );
console.log(_.isTypedArray([]));
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
const _ = require( "lodash" );
console.log(_.isTypedArray( new Int8Array(8)));
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
Share your thoughts in the comments
Please Login to comment...