DEV Community 👩‍💻👨‍💻

Sandeep kamboj
Sandeep kamboj

Posted on

Execute Javascript String using setTimeout


window.sum=0;

window.ExecuteJavascriptString = function()
{

    var data = "var a=3;"+
       "var b=4;"+
       "sum=a+b;"+
       "ShowResult()";
    setTimeout(data, 1);
}
ExecuteJavascriptString();  


window.ShowResult = function(){
    console.log(sum);
    alert(sum);
}

Top comments (0)

Classic DEV Post 👇

Visualizing Promises and Async/Await 🤯

async await