Created
July 4, 2022 08:29
-
-
Save agronom81/ea65cdbdb6c9851cb7cebbca74e3ef82 to your computer and use it in GitHub Desktop.
get type
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 getType(obj) { | |
const type = typeof obj; | |
if(type !== 'object') { | |
return type; | |
} | |
return Object.prototype.toString.call(obj).replace(/^\[object (\S+)\]$/, '$1').toLowerCase(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment