ArrayBuffer.isView()

ArrayBuffer.isView() 方法用来判断传入的参数值是否是一种 ArrayBuffer 视图(view),比如类型化数组对象(typed array objects)或者数据视图( DataView)。

语法

ArrayBuffer.isView(value)

参数

value
被检测的值。

返回值

true
如果提供的参数是一种 ArrayBuffer 视图;
false
提供的参数不是一种 ArrayBuffer 视图类型;

示例

ArrayBuffer.isView();                    // false              
ArrayBuffer.isView([]);                  // false
ArrayBuffer.isView({});                  // false
ArrayBuffer.isView(null);                // false
ArrayBuffer.isView(undefined);           // false
ArrayBuffer.isView(new ArrayBuffer(10)); // false
 
ArrayBuffer.isView(new Uint8Array());    // true
ArrayBuffer.isView(new Float32Array());  // true
ArrayBuffer.isView(new Int8Array(10).subarray(0, 3)); // true

var buffer = new ArrayBuffer(2);
var dv = new DataView(buffer);
ArrayBuffer.isView(dv); // true

规范

Specification Status Comment
Typed Array Specification Obsolete Superseded by ECMAScript 6.
ECMAScript 2015 (6th Edition, ECMA-262)
ArrayBuffer.isView
Standard Initial definition in an ECMA standard.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
isViewChrome Full support 32Edge Full support 12Firefox Full support 29IE Full support 11Opera Full support 19Safari Full support 7WebView Android Full support ≤37Chrome Android Full support 32Firefox Android Full support 29Opera Android Full support 19Safari iOS Full support 7Samsung Internet Android Full support 2.0nodejs Full support 4.0.0

Legend

Full support  
Full support

另见