Skip to content

Instantly share code, notes, and snippets.

@jkohlin
Created December 19, 2022 09:44
Show Gist options
  • Save jkohlin/51bd76b1ea7aa15c3513384265d0773c to your computer and use it in GitHub Desktop.
Save jkohlin/51bd76b1ea7aa15c3513384265d0773c to your computer and use it in GitHub Desktop.
A more fine grained typeof that returns e.g. 'array' | 'date' | etc
/**
* Description
* @param {any} value
* @returns {string}
*/
function typeOf(value) {
return Object.prototype.toString
.call(value)
.replace(/^\[object\s+([a-z]+)\]$/i, '$1')
.toLowerCase()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment