Skip to content

Instantly share code, notes, and snippets.

@themgoncalves
Created August 17, 2020 15:41
Show Gist options
  • Save themgoncalves/457bf50b40da3b58f82866b292d3a4bc to your computer and use it in GitHub Desktop.
Save themgoncalves/457bf50b40da3b58f82866b292d3a4bc to your computer and use it in GitHub Desktop.
Making JavaScript typeof() work - typescript
const typeOf = (value: unknown | unknown[]): string =>
({}.toString
.call(value)
.match(/\s([a-zA-Z]+)/)[1]
.toLowerCase());
export default typeOf;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment