I am developing an application which gets script from server using ajax and execute it, I got success to execute that script. But my problem is I need to restart JavaScript engine to clear running JavaScript.
For Ex.
If I got this script from server.
var d = function () {
setInterval(function () {
console.log(new Date())
}, 1000)
};
d();
And this script will print date for each second, now I want to load another script which print just time. How can I clear previous script from memory? I tried by deleting variable d, but it is not working, and I cant use clearInterval() as there can be any script in ajax call.
In short, I want to reset JavaScript engine of browser to initial stage so I can load new scripts.