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

 

你可能感兴趣的:(js)