Skip to content

Instantly share code, notes, and snippets.

@agronom81
Created July 4, 2022 08:29
Show Gist options
  • Save agronom81/ea65cdbdb6c9851cb7cebbca74e3ef82 to your computer and use it in GitHub Desktop.
Save agronom81/ea65cdbdb6c9851cb7cebbca74e3ef82 to your computer and use it in GitHub Desktop.
get type
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