window._ = {
VARSION:"0.1.0",
each:function(obj,iterator,context){
var index = 0;
try{
if(obj.forEach){
obj.forEach(iterator,context);
}else if(obj.length){
for( var i= 0; i
网速原因 不能上传img 抱歉
我想知道 那个call的作用具体在这段代码的意思是怎么样的
执行的流程是什么样的 谢谢各位
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
call是为了给你保证你提供了第三个参数的时候callback的作用域不受污染.代码的执行顺序可以 debug 一下
iterator.call(context.....
相当于给iterator函数this绑定为context
iterator.call()中,iterator是传入的遍历函数,具体到本例中,就是指匿名函数:因此,call 指的是
Function.prototype.call。具体参见Function.prototype.call() - JavaScript | MDNFunction.prototype.call的签名格式是:thisArg 用来改变函数内部
this指针的绑定。用于指定函数的执行环境