let l = "aaa\"bbb\"aaa";
let command = "let x = \"" + l + "\";";
console.log(command); // >>> let x = "aaa"bbb"aaa";
eval(command);
//-------------------------------------------
// 解法
let l = "aaa\"bbb\"aaa"; (看作 aaa"bbb"aaa)
l = l.replace(/\"|\'/g, function(m){
return ('\\' + m);
});
(把 i 看作 aaa\"bbb\"aaa)