Skip to content

this javascript function returns the type of a variable as string. compared to a usual "typeof" this function differs an OBJECT from ARRAY from FUNCTION from NULL. it also differs a NUMBER from a FLOAT. in the end REGEXP, DATE and ERROR are detected.

Notifications You must be signed in to change notification settings

jaheraho/javascript-gettype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

getType

var undef;
getType('hello github');// -> string
getType(1337);// -> number
getType(false);// -> boolean
getType(1.2);// -> float
getType({});// -> object
getType([1, 2]);// -> array
getType(null);// -> null
getType(undef);// -> undefined
getType(new RegExp('0-9'));// -> regexp
getType(function(){});// -> function
getType(new Date('2013-04-09'));// -> date
getType(new Error('something is wrong here!'));// -> error

License

The project is licensed under the MIT license.

About

this javascript function returns the type of a variable as string. compared to a usual "typeof" this function differs an OBJECT from ARRAY from FUNCTION from NULL. it also differs a NUMBER from a FLOAT. in the end REGEXP, DATE and ERROR are detected.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published