Typed Arrays Recognized by Lodash isTypedArray

The _.isTypedArray method in Lodash is a utility function used to check whether a given value is a typed array object. This guide outlines all the specific typed array types that _.isTypedArray identifies, explains how the method distinguishes them from standard arrays, and details related binary data structures that the function deliberately ignores.

Supported Typed Arrays

In JavaScript, typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers. Lodash's _.isTypedArray evaluates the underlying object's internal tag to determine its type.

The method returns true for instances of the following 11 standard typed arrays:

Example Usage

const _ = require('lodash');

// Returns true
_.isTypedArray(new Int8Array());
_.isTypedArray(new Uint8Array(8));
_.isTypedArray(new Float64Array([1.5, 2.5]));
_.isTypedArray(new BigInt64Array([10n, 20n]));

Objects Not Recognized by _.isTypedArray

While several other JavaScript structures work closely with binary data, they are not typed arrays and will return false:

// Returns false
_.isTypedArray([]);
_.isTypedArray(new Array(10));
_.isTypedArray(new ArrayBuffer(16));
_.isTypedArray(new DataView(new ArrayBuffer(16)));