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

Return true for true array. [see Array-Like Object]

Check If Object is Function

typeof obj === "function"

(also works on Arrow Function)


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

JavaScript in Depth