检测对象的类属性

function classof(o) {
    if(o === null) {
        return "Null";
    }
    if(o === undefined) {
        return "Undefined";
    }
    return Object.prototype.toString.call(o).slice(8, -1);
}

 

posted @ 2016-07-24 12:16  月半流云  阅读(120)  评论(0编辑  收藏  举报