Created
October 2, 2024 07:37
-
-
Save jcayzac/dab5c69f75018f59ae751e78b9572074 to your computer and use it in GitHub Desktop.
Get the type name of anything
This file contains 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
function getTypeName(x: any): string { | |
return x === undefined ? 'undefined' : x === null ? 'null' : /^(?:class|function) (\w+)/.exec(x.constructor.toString())![1] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment