JavaScript Return Object.Type

var getType = function(obj) {
    if (obj == null) {
        return String(obj);
    }
    return typeof obj === 'object' || typeof obj === 'function' ? obj.constructor && obj.constructor.name && obj.constructor.name.toLowerCase() || /functions(.+?)(/.exec(obj.constructor)[1].toLowerCase() : typeof obj;
};
原文地址:https://www.cnblogs.com/shidengyun/p/5841112.html