ES6 introduced template strings delimited by backticks `
.
In which cases would replacing single '
or double "
quotes around a string by backticks yield a different result, or otherwise be unsafe ?
Escaping of existing backticks inside the code is performed as part of the operation.
// before
var message = "Display backtick ` on screen";
// after
var message = `Display backtick \` on screen`;
I understand that any string containing ${...}
would fail as it would be (mis)interpreted as a placeholder. Are there any other relevant patterns ?
Context : this is for the development of a JS compression tool that automatically processes input code. The latter, and the strings it contains is user-provided, hence I have no control over its contents. The only assumption one can make is that it is valid Javascript.
Execution environment can by any recent browser or Node.js.