function typeOf(obj){ // 获取 [object Object] [object Array] [object Null] [object Undefined] let str = Object.prototype.toString.call(obj).split(" ")[1]; // 截取后半段并转为小写 str = str.substring(0, str.length-1).toLowerCase(); console.log(str); } typeOf(new Date())