실행 옵션이 있는 JavaScript

2880 단어 javascript

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
*/

좋은 웹페이지 즐겨찾기