Skip to content

Instantly share code, notes, and snippets.

@naoxink
Last active September 26, 2018 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoxink/2772a234570cfd3e54d86241ee115dcd to your computer and use it in GitHub Desktop.
Save naoxink/2772a234570cfd3e54d86241ee115dcd to your computer and use it in GitHub Desktop.
Utility to check variable types easy
function getType(x){
return Object.prototype.toString.call(x).toLowerCase().replace(/\[(.*)\s|\]$/g, '')
}
// Types (all strings):
//
// number
// string
// boolean
// date
// array
// object
// null
// undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment