Last active
May 3, 2020 00:07
-
-
Save 0x04/e00c802a54118f827358 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
/** | |
* Returns the internal class name of the given object. | |
* @private | |
* @param {*} value | |
* @param {String} [compare] | |
* @returns {Boolean|String} | |
*/ | |
function _is(value, compare) | |
{ | |
var type = Object.prototype.toString.call(value); | |
// Extract the real data type e.g. "[object Object]" | |
// -----------------------------------------^^^^^^ | |
type = type.substring(8, type.length - 1); | |
return (typeof compare == 'string') | |
? (compare.split(/[^$\w]/).indexOf(type) > -1) | |
: type; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment