Created
April 7, 2019 18:12
-
-
Save khaosdoctor/92954e7d1a51828968fd1f2e3db1a727 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const p = new Promise(function (resolve, reject) { | |
setTimeout(() => resolve(100), 2000) // Vai resolver com o valor 100 após 2s | |
}) | |
// Criamos o handler, após 2s ele vai printar "100" | |
p.then((resultado) => console.log(resultado)) | |
// Depois de 4s vamos adicionar um outro handler | |
// Este handler multiplica o valor retornado por 20 | |
setTimeout(() => p.then(result => console.log(result * 20)), 4000) // Vamos ter uma saída "2000" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment