-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lesson5中callback求解 #136
Comments
js回调函数!需要看上下文来判断具体是哪个方法!类似java多态!
发自网易邮箱大师
在2017年06月01日 16:23,gruad 写道:
setTimeout(function () {
concurrencyCount--;
// callback为什么这么写?两个参数,我小白看不懂啊,求解
callback(null, url + ' html content');
}, delay);
callback是什么?是函数吗?看不懂,真心求解(看到是从主函数fetchUrl(url,callback)中传过来的)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
你打印一下这个callback函数看看是什么啊。。 |
callback是回调函数 用于将函数当参数传进去并将结果返回出来的方法,主要用于异步操作时应对非同步响应结果。 |
咦。。。这么热闹 |
这个是async#mapLimit的规定写法,我最开始看也是很疑惑mapLimit怎么知道这些异步函数什么时候执行完,后来仔细看了asyncAPI才知道是必须声明这个名为callback的回调,在异步操作完成时调用,并且第一个参数是null(执行无错时)或者error(出错时)。 |
mapLimit(arr, limit, iterator, callback),iterator里面的callback就是后面的callback,callback参数result是一个iterator里面callback参数的数组。相当于fuck(arguments)参数的伪数组。 |
callback是什么?是函数吗?看不懂,真心求解(看到是从主函数fetchUrl(url,callback)中传过来的)
The text was updated successfully, but these errors were encountered: