js测试对象包含特性

    //Peter Michaux
    function isHostMethod(object, property) {
        var t = typeof object[property];
        return t == 'function' ||
            (!!(t == 'object' && object[property])) ||
                t == 'unknown';
    }

    result = isHostMethod(xhr, "open"); //true
    result = isHostMethod(xhr, "foo"); //false
原文地址:https://www.cnblogs.com/futao/p/2615412.html