JavaScript jQuery promise execution order differs from javascript promise

The following Promise behaves as expected, the Promise in the return statement gets fulfilled and the then right afterwards gets executed before the last call of then:

(new Promise(resolve => resolve(true)))
.then(function(){
    console.log(0);
    return new Promise(resolve => setTimeout(resolve, 1000))
    .then(function() {
        console.log(1);
    });
}).then(function() {
    console.log(2);
});

The result is

0
1
2

But when the first Promise is a jQuery Promise like in the following case

$.post("index.php")
.then(function() {
    console.log(0);
    return new Promise(resolve => setTimeout(resolve, 1000))
    .then(function() {
        console.log(1);
    });
}).then(function() {
    console.log(2);
});

the result is

0 2 1

which indicates, that the second Promise is not passed on as in standard JavaScript promises.
Is there a way to force the standard behavior?

I'm using jQuery 2.0.0.

Answer:1

Here is my code function consec(string) { for (let letter of string) { console.log(letter); } } console.log(consec("zoo")); the result is "z" "o" "o" undefined This is the link of my ...

Here is my code function consec(string) { for (let letter of string) { console.log(letter); } } console.log(consec("zoo")); the result is "z" "o" "o" undefined This is the link of my ...

I am using SVG filter feMorphology's dilate to implement shadow spread for a shape. Am expecting below result. <?xml version="1.0" encoding="UTF-8"?> <svg width="188px" height="209px" ...

I am using SVG filter feMorphology's dilate to implement shadow spread for a shape. Am expecting below result. <?xml version="1.0" encoding="UTF-8"?> <svg width="188px" height="209px" ...

I use Webix 2.5.14. There was a problem with a component Richselect. In this form there is a richselect with options. webix.ui({ view: "form", id:"addAccessForm", borderless: true, elements: [ { ...

I use Webix 2.5.14. There was a problem with a component Richselect. In this form there is a richselect with options. webix.ui({ view: "form", id:"addAccessForm", borderless: true, elements: [ { ...

mdn Object.keys() defines it will return an array of a given object's own enumerable properties. var USComicPublishers = { countryOfOrigin : { value : "USA", enumerable: false, writable: ...

mdn Object.keys() defines it will return an array of a given object's own enumerable properties. var USComicPublishers = { countryOfOrigin : { value : "USA", enumerable: false, writable: ...

  1. object keys object values
  2. object.keys(object)
  3. object.keys object.entries
  4. object.keys(object).length
  5. object.keys object.values javascript
  6. object.keys(object).map
  7. object.keys(object).foreach
  8. object.keys(object).find
  9. object.keys(object) javascript
  10. object.keys(object).reduce
  11. object.keys vs object.getownpropertynames
  12. object.keys vs object.entries
  13. object.keys vs object.values
  14. object.keys vs object.entries performance
  15. object.keys and object.values same order
  16. object.keys empty object
  17. object.keys return object
  18. js object.keys object.values
  19. object.keys nested object
  20. object keys map return object