Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to use await to console

function resolveAfter2Seconds(x) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(x);
    }, 2000);
  });
}

async function f1() {
  var x = await resolveAfter2Seconds(10);
  console.log(x); // 10
}

f1();
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript create image 
Javascript :: jquery datepicker set default date 
Javascript :: server express node js 
Javascript :: browserrouter react 
Javascript :: jquery get data attribute of selected option 
Javascript :: javascript download string as file 
Javascript :: javascript regex escape forward slash 
Javascript :: js get file content from url 
Javascript :: javascript set readonly property 
Javascript :: loopback find with limit 
Javascript :: get random letter js 
Javascript :: document get element by id style 
Javascript :: javascript combine array of arrays 
Javascript :: javascript array remove empty strings 
Javascript :: local storage angular 
Javascript :: sum two objects javascript 
Javascript :: check if variable is undefined or null jquery 
Javascript :: js create element from string 
Javascript :: angular add object to array 
Javascript :: get middle of string js 
Javascript :: javascript check if element is overflowing 
Javascript :: last position of array javascript 
Javascript :: jquery remove disabled property from button 
Javascript :: convert number to string date js 
Javascript :: react state add to array 
Javascript :: javascript stop delay 
Javascript :: jquery disable button 
Javascript :: How to fix CSS & JS not loading issue in cPanel laravel 
Javascript :: how to set state when change viewport react 
Javascript :: FileReader get filename 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =