 
                        if(isFunction(selector) && selector.call!==undefined){
    this.each(function(idx){
        if(!selector.call(this,idx)) nodes.push(this)
    }) 
}这个if语句需要检测两个条件:
1.selector 是不是 Function,下面是isFunction的源码:
function isFunction(value) { 
    return Object.prototype.toString.call(value) == 
                                "[object Function]" }2.判断selector是否具有call方法
分析:
 如果isFunction(selector)成立,说明selector是Function的实例,而Function.prototype中包含call方法.那么isFunction(selector)如果为真的话,selector必然有call方法,也就是selector.call!==undefined必然成立.
那么这个逻辑与运算是否多此一举?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
极端情况
underscore中的实现是这样的:
动态语言就是有这个问题啦,所有都可以随便赋值,所以检查是应该的,你保不准那个二货就给你把call覆盖了