jQuery.when()和ES6的Promise.all()之间有什么区别? [英] What are the differences between jQuery.when() and ES6's Promise.all()?
问题描述
承诺稍后弯曲我的头。现在,两者都非常生锈,而且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()之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!