all about node async await asynchronous and synchronous functions

all about node async await asynchronous and synchronous functions

you can find more node tutorials at

node js sleep() example

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function addprop(obj) {
        await sleep(2000);
        obj.deps = {};
}

var tree={};

addprop(tree);
console.log(tree);
addprop(tree.deps);
console.log(tree);
addprop(tree.deps.deps);
console.log(tree);