Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript execute function after async

function a() {
    return new Promise(function(resolve) {
        setTimeout(function() {
            console.log('a');
            resolve();
        }, 500)
    });
}

function b() {
    return new Promise(function(resolve) {
        setTimeout(function() {
            console.log('b');
            resolve();
        }, 250);
    });
}

a().then(b).then(function() {/* do something else */})
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to update state.item[1] in state using setState? React 
Javascript :: xml vs json 
Javascript :: bind method in javascript 
Javascript :: chrome extension catch shortcut 
Javascript :: stykesheet create 
Javascript :: create table using jade 
Javascript :: vue cli tailwind config 
Javascript :: ready function jq 
Javascript :: math.floor javascript 
Javascript :: How to pass json format data on ajax call 
Javascript :: Material-ui add box icon 
Javascript :: Add jquery in extension 
Javascript :: absolute price in javascript 
Javascript :: how to mark a icon with vector icons in mapview 
Javascript :: autocomplete required material ui 
Javascript :: how to add a message sound in angular 
Javascript :: window onfocus 
Javascript :: three dots in javascript 
Javascript :: click on browser.find_element_by_xpath with href 
Javascript :: sequelize order by nulls last 
Javascript :: check if an element is displayed jquery 
Javascript :: Javascript Map.prototype.size 
Javascript :: get node by value neo4j 
Javascript :: recursive function scheme 
Javascript :: js comment 
Javascript :: javascript unary plus and negation operators 
Javascript :: custom ngModel 
Javascript :: snackbar in react 
Javascript :: install video-react 
Javascript :: why .env file in node.js is not working to connect mongodb 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =