1.0.2 • Published 7 years ago

tidytype v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

TidyType

Same as native function typeof but:

  • returns "regex" for regular expression,
  • "array" for array,
  • "null" for null,
  • "NaN" for NaN and
  • "arguments" for arguments, the native JS object.

How to use

Prerequisites

None

Parameters

val - variable or value of which to return type

Example

//Undefined type
valType() //'undefined'
valType(undefined) //'undefined'

//Number type
valType(0) //'number'
valType(1) //'number'

//NaN type
valType(NaN) //'NaN'

//String type
valType('helloworld') //'string'
valType('') //'string'

//Boolean type
valType(true) //'boolean'
valType(false) //'boolean'

//Function type
valType(function(){}) //'function'

//Object type
valType({}) //'object'

//Array type
valType([]) //'array'

//Null type
valType(null) //'null'

//Regex type
valType(/hello/) //'regex'

//Native arguments object type
var foo = function foo(bar){
	return valType(arguments);
}
foo(1) //'arguments'
});