function classOf(x){ if(x === null) return "NULL"; if(x === undefined) return undefined; return Object.prototype.toString.call(x).slice(8,-1); } var x = 13; console.log(classOf(x));