Last active
January 16, 2019 11:50
-
-
Save marcelomf/f9e1cb93f13382b50e23f864382e9c3a to your computer and use it in GitHub Desktop.
Teste
This file contains 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 funcao1 = function(id){ | |
return {nome: "João", idade: 32, id: id} | |
} | |
const funcao2 = function(callback, id){ | |
setTimeout(function(){ | |
return callback({nome: "João", idade: 32, id: id}) | |
}, 3000) | |
} | |
const funcao3 = (id) => { | |
var p = new Promise(function(resolve, reject){ | |
setTimeout(function(){ | |
resolve({nome: "João", idade: 32, id: id}) | |
}, 6000); | |
}); | |
return p | |
} | |
async function main() { | |
funcao2(function(dados){ | |
console.log(dados) | |
}, 3); | |
console.log(await funcao3(1)) | |
console.log(funcao3()) | |
funcao3(2) | |
.then(function(dados){ | |
console.log(dados) | |
}); | |
console.log(funcao1(0)) | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment