Plain old JavaScript uses the typeof
operator to determine the underlying type of a variable or value and returns the string value of the type, like this:
typeof 37 would return 'number'
typeof 3.14 would return 'number'
typeof "37" would return 'string'
typeof "" would return 'string'
typeof function() {} would return 'function'
typeof true would return 'boolean'
typeof false woulld return 'boolean'
typeof undefined would return 'undefined'
typeof {1, 2, 3} would return 'object'
typeof null would return 'object'
I believe the only two types you should care about are 'number'
and 'string'
, because you can coerce a 'string'
to a 'number'
.
I would put a check at the top of your function to see if the min
and max
are both either 'number'
or 'string'
and if not, then bail out of your function.