有这样一段代码:
function traverse(){
return Array.prototype.filter.call(document.querySelectorAll('body *'), function(node){
return node.offsetWidth > 50 && node.offsetHeight > 50;
});
}
1.call有两个参数,第一个是指作用域,第二个是参数,这段代码中call不能替换为apply,是否是因为apply要求的第二个参数是数组的原因?
2.document.querySelectorAll('body *')的返回值是nodelist,而nodelist不属于array,filter是数组的方法,为什么可以应用到这里??
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ringa_lee