【发布时间】:2015-10-13 19:41:44
【问题描述】:
我想了解我们在javascript中经常使用回调函数的地方,你能举一些真实的项目例子吗?我了解了这个概念以及如何创建回调函数,但从未在实际应用程序中看到过它......顺便说一句,我的意思是使用 vanilla javascript 而不是 jquery 等......
【问题讨论】:
-
非常感谢 -1。如果您可以通过 Google 搜索出您可以构建使用回调的项目,请告诉我
-
不幸的是,这不是 Stack Overflow 所针对的问题类型。 SO 适用于有关代码的特定问题。这不是为了建议。见stackoverflow.com/help/on-topic
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. -
最简单的回调示例是
Array.prototype.forEach函数,它需要为数组中的每个项目调用的回调。例子:[3,2,5,6,7].forEach(i => console.log(i))在这个例子中,箭头函数是一个回调函数。主要区别在于这个回调是同步的,而回调通常是异步的。
标签: javascript callback project