admin管理员组文章数量:1336623
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?
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?
-
Is
$
anddocument.querySelectorAll
same ? – Rayon Commented Jun 15, 2016 at 7:22 -
1
@Rayon: I thought
$
was the same asdocument.querySelector
and$$
was the same asdocument.querySelectorAll
in a browser devtools console. But$
in jQuery is thejQuery
object. – hippietrail Commented Jun 15, 2016 at 7:25 -
That is what my point is! How could you pare
jQuery
withJavaScript-Promise
? – Rayon Commented Jun 15, 2016 at 7:27 - 2 Then I don't get your point. You can pare anything. I'm not paring all of jQuery to just the promises of native JS, I'm paring one of jQuery's promise functions with one of native JS's promise functions. – hippietrail Commented Jun 15, 2016 at 7:31
1 Answer
Reset to default 9Promise.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.
本文标签: javascriptWhat are the differences between jQuerywhen() and ES639s Promiseall()Stack Overflow
版权声明:本文标题:javascript - What are the differences between jQuery.when() and ES6's Promise.all()? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742409534a2469507.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论