对回调函数的理解

回调函数: A callback is a function that is passed as an argument to another function and is executed after its parent function has completed.

我的理解就是, 回调函数是一个参数, 将这个参数传到另一个函数(主函数)中, 主函数执行完了, 再回来调用这个函数, 就是回调函数.

主函数不用等待回调函数执行完, 可以继续执行自己的代码.

所以一般情况下回调函数都用在比较耗时的操作上, 例如ajax请求, 文件io操作等.

posted @ 2018-08-20 19:10  BabyJoy❤️  阅读(100)  评论(0编辑  收藏  举报