Why are the \ removed in the result and how can I prevent this? I need to keep the escaped string as it is.
const result = [
'TITLE=Frontend',
'DESCRIPTION=The\ frontend\ application'
].join('\n')
Expected result is:
TITLE=Frontend
DESCRIPTION=The\ frontend\ application
Update
The other way would be to join the string and escape the complete string after joining. I think this would be even better...
join() isn't removing anything. The backslash isn't in the original strings. It's just escaping the spaces, but space doesn't require escaping.
You need to escape the backslash if you need it to be included in the string literally.
const result = [
'TITLE=Frontend',
'DESCRIPTION=The\\ frontend\\ application'
].join('\n')
console.log(result);