JS: 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

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