Asynchronous and Synchronous in NodeJS

 


let x=10;
let y=200;

let waitingData=new Promise((resolve,reject)=>{
    setTimeout(()=>{
        resolve(30);
    },2000);
});


waitingData.then((data)=>{
    y=data;
    console.log(x+y);
})








// Asynchronous Function



setTimeout(()=>{
    y=45;

},2000);

console.log(x+y);



console.log("Hello Anand !");

setTimeout(()=>{
    console.log("this is new ");
},2000);

console.log("Hello Node JS!");

console.log("Good Morning! ")
















Post a Comment

0 Comments