承诺稍后弯曲我的头。现在,两者都非常生锈,而且jQuery承诺,其他承诺图书馆和新的本机JS承诺之间存在着微小和重大的差异,当我尝试使这些东西工作时,我的头更加弯曲。 >
好像 jQuery.when () 和 Promise.all() 做同样的事情,但是我们应该记住一些重要的区别吗?
解决方案Promise.all() take array of 承诺或简单的 JS对象作为参数,所以您需要通过索引访问结果。
jQuery.when()采用多个参数,这些参数是简单的 JS对象或 jQuery Deferred ,所以你可以通过变量名来访问你的结果。
I learned promises with jQuery and then didn't do much programming for a couple of years. Now I want to do some stuff using native ES6 promises.
Promises bent my head a little back then. Now with both being quite rusty on top of that and there being minor and major differences between jQuery promises, other promise libraries, and the new native JS promises, my head gets even more bent when I try to get this stuff working.
It seems like jQuery.when() and Promise.all() do the same thing, but are there some important differences we should keep in mind?
解决方案Promise.all() takes Array of Promises or plain JS objects as argument so you need to access results by index.
jQuery.when() takes multiple arguments which are plain JS objects or jQuery Deferred, so you can access your result by variable name.
更多推荐
jQuery.when()和ES6的Promise.all()之间有什么区别?
发布评论