Run Code In JavaScript With options like:
- Use Unchangeable variables:
var options = {
UseConstants: "true"
}
var JavaScriptCode = `
var js = "JavaScript";
console.log(js);
js = "wow";
// Cannot Change Value
` // JavaScript Code That will be affected with options
if(options.UseConstants){
var u = URL.createObjectURL(new Blob([JavaScriptCode.replaceAll("var", "const")], {type: "application/javascript"}));
var script = document.createElement("script");
document.head.appendChild(script);
script.src = u;
script.defer = "";
}
// Gives Error: Assignment to constant variable.
/*
Code After Change:
const js = "JavaScript";
console.log(js);
js = "wow";
// Cannot Change Value
*/
Top comments (0)