window.btoa( // here programcode // ) 如何做到这一点

window.btoa( // here programcode // ) how to do that?

本文关键字:何做 这一点 programcode btoa here window      更新时间:2023-09-26

我的目标是用window.btoa()对我的编程代码进行编码,但是我怎样才能写一个包含编程码的字符串 - 问题是comipiler认为字符串在代码中的第一个"之后结束。

例:

var engine = '';
function all_this_in_the_string() {
  var examples_string = 'single';
  var double_ = "double";
}
// I have about 600 lines code with single and double quotes...of course the code is in more than one line.
// Is there a way to get this code into the string (engine) that i can encode with the line above ?
console.log(window.btoa(engine));

迎接大卫

您需要

在单引号和双引号之间变化。

var engine = 'function() { var examples_string = "here_is_the_problem"}';