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?

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.

本文标签: javascriptWhat are the differences between jQuerywhen() and ES639s Promiseall()Stack Overflow