Last active
August 29, 2015 13:56
-
-
Save ivan-demchenko/8912213 to your computer and use it in GitHub Desktop.
Get the real type of a value
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
/** | |
* Thanks to Dmitry Baranovsky for his knowledge sharing: | |
* http://dmitry.baranovskiy.com/post/typeof-and-friends | |
*/ | |
function is (value) { | |
return { | |
aan: function (type) { | |
type = String(type).toLowerCase(); | |
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase() === type; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment