Skip to content

Instantly share code, notes, and snippets.

@joshuaalpuerto
Created April 2, 2022 08:40
Show Gist options
  • Save joshuaalpuerto/fc58ecb70543bad071eb3737d1ed0198 to your computer and use it in GitHub Desktop.
Save joshuaalpuerto/fc58ecb70543bad071eb3737d1ed0198 to your computer and use it in GitHub Desktop.
Getting raw type
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