JavaScript: Determine Type of Object

By Xah Lee. Date: . Last updated: .

How to find out if a object is function, array, date, regex, etc?

Check If Object is Array

Array.isArray(obj)
Return true for true array. [see Array-Like Object]

Check If Object is Function

typeof obj === "function"

(also works on Arrow Function)

Other

The most reliable and generic way to determine the type of object is this:

Reflect.apply( Object.prototype.toString , val, [] )

For detail, see Object.prototype.toString

JavaScript Value Types

JavaScript Object and Inheritance

BUY
Ξ£JS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc