SyntaxFix
Write A Post
Hire A Developer
Questions
Slightly hacky, but it works:
const input = '\text';_x000D_ const output = JSON.stringify(input).replace(/((^")|("$))/g, "").trim();_x000D_ _x000D_ console.log({ input, output });_x000D_ // { input: '\text', output: '\\text' }