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.