async await
const data = async () => {
const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
console.log(await got.json())
}
data();
async await
const data = async () => {
const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
console.log(await got.json())
}
data();
How does asynchronous javascript work?
const printProcess = () => {
console.log('it will print 2nd');
var currentTime = new Date().getTime();
while (currentTime + 3000 >= new Date().getTime());
console.log('it will print after added 3 second with current time')
}
console.log('it will print 1st ');
printProcess(); //follow arrow funtion after 1st print
console.log('it will print at the end');
//Expected output below:
// it will print 1st
// it will print 2nd
// it will print after added 3 second with current time
// it will print at the end
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us