Created
March 18, 2019 13:21
-
-
Save ionurboz/9a6bbbf3d9416253a4f09bc94028ad26 to your computer and use it in GitHub Desktop.
More accurately check the type of a JavaScript object
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
/** | |
* More accurately check the type of a JavaScript object | |
* @param {Object} obj The object | |
* @return {String} The object type | |
*/ | |
var trueTypeOf = function (obj) { | |
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment