SkillSeevaSkillSeeva
HomeResourcesScheduleRoadmapTeam
Back to Categories
Current Path
JavaScript
Syntax & VariablesOperatorsFunctionsObjectsEventsString MethodsArrays & MethodsDate & MathLogic (If/Switch/Loops)DOM ManipulationES6+ FeaturesScope & HoistingThe 'this' KeywordJS ModulesClassesAsync/Await & PromisesDebuggingWeb APIs (Fetch, Storage)JSON
Jump to topic:
Syntax & VariablesOperatorsFunctionsObjectsEventsString MethodsArrays & MethodsDate & MathLogic (If/Switch/Loops)DOM ManipulationES6+ FeaturesScope & HoistingThe 'this' KeywordJS ModulesClassesAsync/Await & PromisesDebuggingWeb APIs (Fetch, Storage)JSON

Async/Await & Promises

Handling asynchronous operations.
javascript
let myPromise = new Promise(function(myResolve, myReject) {
  // "Producing Code" (May take some time)
  myResolve(); // when successful
  myReject();  // when error
});

// Async/Await
async function myFunction() {
  return "Hello";
}

async function display() {
  let myPromise = new Promise(function(resolve) {
    setTimeout(function() {resolve("I love You !!");}, 3000);
  });
  document.getElementById("demo").innerHTML = await myPromise;
}
16 / 19