JSFiddle - React, Tailwind, and code Playground

by Dru Dro

JavaScript

var a = 1;
setTimeout(function timeout() {
    console.log(a);//---------------------------
    a = 2;
}, 0);

var p1 = new Promise(function(resolve, reject) {
    console.log(a);//---------------------------
    a = 3;
    resolve();
});

var p2 = new Promise(function(resolve, reject) {
    console.log(a);//---------------------------
    a = 5;
    resolve();
});

p1.then(function(){
    // ***
});

console.log(a);//---------------------------
a = 4;

p2.then(function(){
    // ***
});