-
-
Save littlepsylo/6823155 to your computer and use it in GitHub Desktop.
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
var typeOf = (function(Object, RegExp){ | |
// WTFPL License - http://en.wikipedia.org/wiki/WTFPL | |
// thanks to @jdalton and @ljharb | |
var toString = Object.prototype.toString, | |
cache = (Object.create || Object)(null); | |
return function typeOf(Unknown) { | |
var asString = typeof Unknown; | |
return asString == 'object' ? ( | |
Unknown === null ? 'null' : ( | |
cache[asString = toString.call(Unknown)] || ( | |
cache[asString] = asString | |
.slice(asString.indexOf(' ') + 1, -1) | |
.toLowerCase() | |
) | |
) | |
) : asString; | |
}; | |
}(Object, RegExp)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment