# util.types

util.types provides type checks for different kinds of built-in objects. Unlike instanceof or Object.prototype.toString.call(value), these checks do not inspect properties of the object that are accessible from JavaScript (like their prototype), and usually have the overhead of calling into C++.

The result generally does not make any guarantees about what kinds of properties or behavior a value exposes in JavaScript. They are primarily useful for addon developers who prefer to do type checking in JavaScript.

Availability
8.1.0
8.1.0
9.2.0
Extends
Object

NOTE

This is an abstract type. Any object of this structure can be used where this type is used.

# Methods

# isAnyArrayBuffer

Availability
8.1.0
8.1.0
9.2.0
isAnyArrayBuffer(value) Boolean

Returns true if the value is a built-in ArrayBuffer or SharedArrayBuffer instance.

See also util.types.isArrayBuffer() and util.types.isSharedArrayBuffer().

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isArgumentsObject

Availability
8.1.0
8.1.0
9.2.0
isArgumentsObject(value) Boolean

Returns true if the value is an arguments object.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isArrayBuffer

Availability
8.1.0
8.1.0
9.2.0
isArrayBuffer(value) Boolean

Returns true if the value is a built-in ArrayBuffer instance. This does not include SharedArrayBuffer instances. Usually, it is desirable to test for both; See util.types.isAnyArrayBuffer() for that.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isArrayBufferView

Availability
8.1.0
8.1.0
9.2.0
isArrayBufferView(value) Boolean

Returns true if the value is an instance of one of the ArrayBuffer views, such as typed array objects or DataView. Equivalent to ArrayBuffer.isView().

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isAsyncFunction

Availability
8.1.0
8.1.0
9.2.0
isAsyncFunction(value) Boolean

Returns true if the value is an async function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isBigInt64Array

Availability
8.1.0
8.1.0
9.2.0
isBigInt64Array(value) Boolean

Returns true if the value is a Bigint64Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isBigUint64Array

Availability
8.1.0
8.1.0
9.2.0
isBigUint64Array(value) Boolean

Returns true if the value is a BigUint64Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isBooleanObject

Availability
8.1.0
8.1.0
9.2.0
isBooleanObject(value) Boolean

Returns true if the value is a boolean object, e.g. created by new Boolean().

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isBoxedPrimitive

Availability
8.1.0
8.1.0
9.2.0
isBoxedPrimitive(value) Boolean

Returns true if the value is any boxed primitive object, e.g. created by new Boolean(), new String() or Object(Symbol()).

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isDataView

Availability
8.1.0
8.1.0
9.2.0
isDataView(value) Boolean

Returns true if the value is a built-in DataView instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isDate

Availability
8.1.0
8.1.0
9.2.0
isDate(value) Boolean

Returns true if the value is a built-in Date instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isFloat32Array

Availability
8.1.0
8.1.0
9.2.0
isFloat32Array(value) Boolean

Returns true if the value is a built-in Float32Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isFloat64Array

Availability
8.1.0
8.1.0
9.2.0
isFloat64Array(value) Boolean

Returns true if the value is a built-in Float64Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isGeneratorFunction

Availability
8.1.0
8.1.0
9.2.0
isGeneratorFunction(value) Boolean

Returns true if the value is a generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isGeneratorObject

Availability
8.1.0
8.1.0
9.2.0
isGeneratorObject(value) Boolean

Returns true if the value is a generator object as returned from a built-in generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isInt16Array

Availability
8.1.0
8.1.0
9.2.0
isInt16Array(value) Boolean

Returns true if the value is a built-in Int16Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isInt32Array

Availability
8.1.0
8.1.0
9.2.0
isInt32Array(value) Boolean

Returns true if the value is a built-in Int32Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isInt8Array

Availability
8.1.0
8.1.0
9.2.0
isInt8Array(value) Boolean

Returns true if the value is a built-in Int8Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isMap

Availability
8.1.0
8.1.0
9.2.0
isMap(value) Boolean

Returns true if the value is a built-in Map instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isMapIterator

Availability
8.1.0
8.1.0
9.2.0
isMapIterator(value) Boolean

Returns true if the value is an iterator returned for a built-in Map instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isNativeError

Availability
8.1.0
8.1.0
9.2.0
isNativeError(value) Boolean

Returns true if the value is an instance of a built-in Error type.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isNumberObject

Availability
8.1.0
8.1.0
9.2.0
isNumberObject(value) Boolean

Returns true if the value is a number object, e.g. created by new Number().

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isPromise

Availability
8.1.0
8.1.0
9.2.0
isPromise(value) Boolean

Returns true if the value is a built-in Promise.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isRegExp

Availability
8.1.0
8.1.0
9.2.0
isRegExp(value) Boolean

Returns true if the value is a regular expression object.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isSet

Availability
8.1.0
8.1.0
9.2.0
isSet(value) Boolean

Returns true if the value is a built-in Set instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isSetIterator

Availability
8.1.0
8.1.0
9.2.0
isSetIterator(value) Boolean

Returns true if the value is an iterator returned for a built-in Set instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isSharedArrayBuffer

Availability
8.1.0
8.1.0
9.2.0
isSharedArrayBuffer(value) Boolean

Returns true if the value is a built-in SharedArrayBuffer instance. This does not include ArrayBuffer instances. Usually, it is desirable to test for both; See util.types.isAnyArrayBuffer() for that.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isStringObject

Availability
8.1.0
8.1.0
9.2.0
isStringObject(value) Boolean

Returns true if the value is a string object, e.g. created by new String().

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isSymbolObject

Availability
8.1.0
8.1.0
9.2.0
isSymbolObject(value) Boolean

Returns true if the value is a symbol object, created by calling Object() on a Symbol primitive.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isTypedArray

Availability
8.1.0
8.1.0
9.2.0
isTypedArray(value) Boolean

Returns true if the value is a built-in TypedArray instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isUint16Array

Availability
8.1.0
8.1.0
9.2.0
isUint16Array(value) Boolean

Returns true if the value is a built-in Uint16Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isUint32Array

Availability
8.1.0
8.1.0
9.2.0
isUint32Array(value) Boolean

Returns true if the value is a built-in Uint32Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isUint8Array

Availability
8.1.0
8.1.0
9.2.0
isUint8Array(value) Boolean

Returns true if the value is a built-in Uint8Array instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isUint8ClampedArray

Availability
8.1.0
8.1.0
9.2.0
isUint8ClampedArray(value) Boolean

Returns true if the value is a built-in Uint8ClampedArray instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isWeakMap

Availability
8.1.0
8.1.0
9.2.0
isWeakMap(value) Boolean

Returns true if the value is a built-in WeakMap instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean

# isWeakSet

Availability
8.1.0
8.1.0
9.2.0
isWeakSet(value) Boolean

Returns true if the value is a built-in WeakSet instance.

Parameters

Name Type Description
value any

value to check

Returns

Type
Boolean