Answers for "How does asynchronous javascript work?"

1

asynchronous javascript

console.log ('Starting');
let image;

fetch('coffee.jpg').then((response) => {
  console.log('It worked :)')
  return response.blob();
}).then((myBlob) => {
  let objectURL = URL.createObjectURL(myBlob);
  image = document.createElement('img');
  image.src = objectURL;
  document.body.appendChild(image);
}).catch((error) => {
  console.log('There has been a problem with your fetch operation: ' + error.message);
});

console.log ('All done!');
Posted by: Guest on July-14-2020
-1

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 "How does asynchronous javascript work?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language