Last active
July 22, 2020 12:03
-
-
Save kellyjoe256/4c7797a94aa7aaad657c583740ca9617 to your computer and use it in GitHub Desktop.
An alternative way of determining type in JavaScript
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
function is(value) { | |
const toString = Object.prototype.toString; | |
// OR return ({}).toString.call(value).slice(8, -1).toLowerCase(); | |
return toString.call(value).slice(8, -1).toLowerCase(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment