/* function natureof(variable, [included types])
included types are
null - null will result in "undefined" or if included, will result in "null"
NaN - NaN will result in "undefined" or if included, will result in "NaN"
-infinity - will separate negative -Inifity from "Infinity"
number - will split number into "int" or "double"
array - will separate "array" from "object"
empty - empty "string" will result in "empty" or
empty=undefined - empty "string" will result in "undefined"
*/
function natureof(v, ...types){
/*null*/ if(v === null) return types.includes('null') ? "null" : "undefined";
/*NaN*/ if(typeof v == "number") return (isNaN(v)) ? types.includes('NaN') ? "NaN" : "undefined" :
/*-infinity*/ (v+1 === v) ? (types.includes('-infinity') && v === Number.NEGATIVE_INFINITY) ? "-infinity" : "infinity" :
/*number*/ (types.includes('number')) ? (Number.isInteger(v)) ? "int" : "double" : "number";
/*array*/ if(typeof v == "object") return (types.includes('array') && Array.isArray(v)) ? "array" : "object";
/*empty*/ if(typeof v == "string") return (v == "") ? types.includes('empty') ? "empty" :
/*empty=undefined*/ types.includes('empty=undefined') ? "undefined" : "string" : "string";
else return typeof v
}
// DEMO
let types = [null, "", "string", undefined, NaN, Infinity, -Infinity, false, "false", true, "true", 0, 1, -1, 0.1, "test", {var:1}, [1,2], {0: 1, 1: 2, length: 2}]
for(i in types){
console.log("natureof ", types[i], " = ", natureof(types[i], "null", "NaN", "-infinity", "number", "array", "empty=undefined"))
}