Created
January 11, 2018 04:10
-
-
Save crapthings/4aaecb00c53609fdd4b3aaa336b6c35f to your computer and use it in GitHub Desktop.
check type
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
function isString(target) { | |
return isType(target, 'String') | |
} | |
function isNumber(target) { | |
return isType(target, 'Number') | |
} | |
function isDate(target) { | |
return isType(target, 'Date') | |
} | |
function isFunction(target) { | |
return isType(target, 'Function') | |
} | |
function isObject(target) { | |
return isType(target, 'Object') | |
} | |
function isArray(target) { | |
return isType(target, 'Array') | |
} | |
function isType(target, type) { | |
return Object.prototype.toString.call(target) === `[object ${type}]` ? true : false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment