Created
August 19, 2014 23:24
-
-
Save webbower/90b06f72c8067541ae6a to your computer and use it in GitHub Desktop.
Value testing functions
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 existy(val) { | |
return val !== undefined && val !== null && !isRealNaN(val); | |
} | |
function toClass(obj) { | |
return Object.prototype.toString.call(obj); | |
} | |
function isMaker(type) { | |
return function(val) { | |
return toClass(val).slice(8, -1) === type; | |
} | |
} | |
var isFunction = isMaker('Function'); | |
var isString = isMaker('String'); | |
var isNumber = isMaker('Number'); | |
var isArguments = isMaker('Arguments'); | |
function isRealNaN(val) { | |
return isNumber(val) && val != +val; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment