Hacker News new | ask | show | jobs
by threatofrain 1709 days ago
How about

any => Object.prototype.toString.call(any).slice(8, -1)

3 comments

I really like this package, because it not only uses the method you mentioned for checking types, but is written in TS, so you get the type checking feedback.

https://github.com/sindresorhus/is

or even this

typeName = Object.prototype.toString.call

bit more self-explanatory `it => Object.prototype.toString.call(it).match(/^\[object (\w+)]/).pop()`