Answers for "asynchronous functions javascript"

16

async awiat

const data = async ()  => {
  const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  
  console.log(await got.json())
}

data();
Posted by: Guest on July-24-2020
0

Asynchronous in javascript

//Asynchronous JavaScript
console.log('I am first');
setTimeout(() => {
    console.log('I am second')
}, 2000)
setTimeout(() => {
    console.log('I am third')
}, 1000)
console.log('I am fourth')
//Expected output:
// I am first
// I am fourth
// I am third
// I am second
Posted by: Guest on September-07-2021
-2

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
Posted by: Guest on September-04-2021

Code answers related to "asynchronous functions javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language