Underscore.js _.isDataView() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is a DataView (official Underscore docs). ArrayBuffers, TypedArrays, and regular arrays return false.

Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.

Syntax

Call _.isDataView. Start with this line.

Underscore
_.isDataView(object)
CallWhat it does
_.isDataView(object)Primary signature.
_.isDataView(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.isDataView(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official Docs

The docs show a DataView passing and a regular array failing.

Underscore
_.isDataView(new DataView(new ArrayBuffer(8)));
// → true

_.isDataView([]);
// → false
Try It Yourself

How It Works

  1. Allocate a buffer. new ArrayBuffer(8) creates 8 raw bytes.
  2. Wrap in DataView. That wrapper is what Underscore looks for.
  3. Check. _.isDataView(…) → true.
  4. Array fails. [] is a JS list, not a binary view → false.

Example 2 — Look-alikes Fail

null, strings, and arrays fail. A real DataView passes.

Underscore
var view = new DataView(new ArrayBuffer(16));

console.log(_.isDataView(null));   // false
console.log(_.isDataView(""));     // false
console.log(_.isDataView([]));     // false
console.log(_.isDataView(view));   // true
Try It Yourself

How It Works

  1. null / string / array. None is a DataView → all false.
  2. Real view. Built with new DataView(…) → true.
  3. Safe call. Passing null does not throw.
  4. Rule. Only DataView instances pass.

Example 3 — Buffer vs TypedArray vs DataView

All three can share the same bytes. Only the DataView passes.

Underscore
var buffer = new ArrayBuffer(8);
var bytes = new Uint8Array(buffer);
var view = new DataView(buffer);

console.log(_.isDataView(buffer));       // false
console.log(_.isDataView(bytes));        // false
console.log(_.isDataView(view));         // true
console.log(_.isDataView(bytes.buffer)); // false
Try It Yourself

How It Works

  1. Buffer. Raw memory → use _.isArrayBuffer.
  2. TypedArray. Indexed typed view → use _.isTypedArray.
  3. DataView. Multi-byte get/set API → _.isDataView is true.
  4. .buffer. Still an ArrayBuffer, not a DataView → false.

Example 4 — Offset vs Type

Full and sliced DataViews both pass. Offset is a separate property.

Underscore
var buffer = new ArrayBuffer(8);
var full = new DataView(buffer);
var slice = new DataView(buffer, 2, 4);

console.log(_.isDataView(full));   // true
console.log(_.isDataView(slice));  // true
console.log(slice.byteOffset, slice.byteLength); // 2 4
Try It Yourself

How It Works

  1. Full view. Covers the whole buffer → still a DataView.
  2. Sliced view. Starts at offset 2 with length 4 → still a DataView.
  3. Type vs layout. _.isDataView ignores offset and length.
  4. Read layout. Use byteOffset / byteLength when size matters.

Browser & Runtime Support

_.isDataView ships with Underscore.js 1.11.0+. It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. DataView itself is a standard ES2015 feature.

✓ Stable · Underscore 1.11+

_.isDataView()

Available in [email protected]+ (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded and DataView exists. Older IE/Edge use a getInt8 + buffer fallback.

100% With Underscore 1.11+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isDataView Underscore 1.11+

Bottom line: Safe for production once Underscore 1.11+ is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isDataView(object) returns true only when the value is a DataView — for example new DataView(new ArrayBuffer(8)). Regular arrays, ArrayBuffers, TypedArrays, strings, numbers, null, and plain objects return false.
_.isDataView(new DataView(new ArrayBuffer(8))) returns true. The docs wrap a real ArrayBuffer in a DataView on purpose: that is the type the helper looks for.
No. An ArrayBuffer is the raw byte block. A DataView is a reader sitting on top of that block. Underscore treats an ArrayBuffer as not a DataView.
No. A Uint8Array is a typed view onto a buffer, not a DataView. Use DataView when you need mixed-endian get/set methods such as getInt8 or getFloat64.
typeof a DataView is "object", so typeof is too broad. instanceof DataView usually agrees in the same window. Underscore uses the [object DataView] tag, with a getInt8 plus buffer fallback in older IE/Edge.
No. It is a stable Underscore helper added in version 1.11.0, along with _.isArrayBuffer and _.isTypedArray. Use it before calling getInt8 or setFloat64.

Next: _.isTypedArray()

Detect typed binary views such as Int8Array and Uint8Array.

_.isTypedArray() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful