You are reading a single comment by @user90002 and its replies. Click here to read the full conversation.
  • I try use promise, but it's work strange:

    const p = new Promise(function(resolve, reject) {
      setTimeout(resolve, 100);
      setTimeout(reject, 200);
    });
    
    p.then(function() {
        console.log('resolved');
    }).catch(function() {
        console.log('rejected');
    });
    

    output:

    resolved
    Uncaught Error: Unhandled promise rejection: undefined

    Bolded text printed, because reject called after resolve, but promise must be ignore change state at second call.

    And what about async\await?

About

Avatar for user90002 @user90002 started