A tiny, highly testable file; easy to add to your project and simple to use.
- No duck typing
- Works cross-iframe
- Works with non-primitive constructed objects (
new String()
,new Number()
, etc)
Meta
- author: @tchaflich
- license: MIT
Grab the type JavaScript believes the parameter to be. Native types will often have an uppercased string, so this function converts to lowercase for ease of use.
something
any
Returns string
Is the input a string?
something
any
Returns boolean
Is the input a number? This will return true for NaN, despite how silly that sounds. It is still of a "numeric" type, much like Infinity.
something
any
Returns boolean
Is the input an array?
something
any
Returns boolean
Is the input a function?
something
any
Returns boolean
Is the input an object? Defining 'object' in javascript is not a trivial exercise - the specification used here is that the argument is a non-primitive.
something
any
Returns undefined
Is the input undefined?
something
any
Returns boolean
Is the input null? This one is really just in here for completion's sake.
something
any
Returns boolean
Is the input a boolean?
something
any
Returns boolean