.replace() ↔
.replace() to escape all double quotes via RegExp Literal Notation
.replace(/"/g, '\\"')
.replace() to escape all single quotes via RegExp Literal Notation
.replace(/'/g, "\\'")
.replace() to remove all line breaks via RegExp Literal Notation
.replace(/\n/g, "")
References
.replace(/"/g, '\\"')
.replace(/'/g, "\\'")
.replace(/\n/g, "")