Created
April 2, 2022 08:40
-
-
Save joshuaalpuerto/fc58ecb70543bad071eb3737d1ed0198 to your computer and use it in GitHub Desktop.
Getting raw 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 toRawType (value) { | |
let _toString = Object.prototype.toString; | |
let str = _toString.call(value) | |
return str.slice(8, -1) | |
} | |
toRawType('test') === 'String' | |
toRawType(1) === 'Number' | |
toRawType({}) === 'Object' | |
toRawType([]) === 'Array' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment