JS: Find Object's sub-type

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

Others

const my_obj = new Date();

console.log(
 Reflect.apply(Object.prototype.toString, my_obj, []),
);
// [object Date]