Chocolate1999 / Front-end-learning-to-organize-notes

☀小狮子前端の学习☁整理笔记❤ Front-end-learning-to-organize-notes 帮你整理好前端知识体系、更高效地吸收经验成果;另附小狮子前端进阶小册食用指北,敬请关注!
https://chodocs.cn/
MIT License
1.09k stars 152 forks source link

实现类型判断函数 #480

Open Chocolate1999 opened 3 years ago

Chocolate1999 commented 3 years ago
function getType(param) {
    const type = Object.prototype.toString.call(param).slice(8, -1);
    if (type === "Object") {
        return param.constructor.name;
    } else {
        return type;
    }
}