最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论