Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How about

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



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()`




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: