Created
August 17, 2020 15:41
-
-
Save themgoncalves/457bf50b40da3b58f82866b292d3a4bc to your computer and use it in GitHub Desktop.
Making JavaScript typeof() work - typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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