javascript - What are the differences between jQuery.when() and ES6's Promise.all()? - Stack Overflow

I learned promises with jQuery and then didn't do much programming for a couple of years. Now I wa

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?

Share Improve this question asked Jun 15, 2016 at 7:14 hippietrailhippietrail 17k21 gold badges109 silver badges179 bronze badges 4
  • Is $ and document.querySelectorAll same ? – Rayon Commented Jun 15, 2016 at 7:22
  • 1 @Rayon: I thought $ was the same as document.querySelector and $$ was the same as document.querySelectorAll in a browser devtools console. But $ in jQuery is the jQuery object. – hippietrail Commented Jun 15, 2016 at 7:25
  • That is what my point is! How could you pare jQuery with JavaScript-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
Add a ment  | 

1 Answer 1

Reset to default 9

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742409535a4438533.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信