News for hackers. Stuff that matters.
Re:Tricks I wish I knew when I learned TypeScript by threatofrain on Tuesday October 12, 2021 @06:11AM (#28838027)
How about

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

Re:Tricks I wish I knew when I learned TypeScript by JoBrad on Tuesday October 12, 2021 @07:17AM (#28838361)
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

Re:Tricks I wish I knew when I learned TypeScript by nsonha on Tuesday October 12, 2021 @06:46AM (#28838187)
or even this

typeName = Object.prototype.toString.call

Re:Tricks I wish I knew when I learned TypeScript by nsonha on Tuesday October 12, 2021 @06:40AM (#28838152)
bit more self-explanatory `it => Object.prototype.toString.call(it).match(/^\[object (\w+)]/).pop()`