function getType(val) {
if (val === null) {
return "null";
}
if (typeof val === "object") {
const type = Object.prototype.toString.call(val).slice(8, -1)
return type;
} else {
return typeof val + "";
}
}
console.log(getType({ a: 1 }));