I have this var
var x = \"\";
Which is
-
You can use JSON.parse to unescape slashes:
function unescapeSlashes(str) {
// add another escaped slash if the string ends with an odd
// number of escaped slashes which will crash JSON.parse
let parsedStr = str.replace(/(^|[^\\])(\\\\)*\\$/, "$&\\");
try {
parsedStr = JSON.parse(`"${parsedStr}"`);
} catch(e) {
return str;
}
return parsedStr ;
}