Posts

Showing posts with the label newline

Keeping newline n as is in JavaScript object

Keeping newline n as is in JavaScript object I want to keep string values in my insert object as is This works fine, the n is kept {insert: "erferferfnerferferf"} This {insert: "nnn"} And this becomes a problem {insert: "n"} it makes the string like this {insert: " "} I want the string to keep the "nnn" rather than becoming a bunch of new lines try using .trim() , it may solve your problem. – Raghav Garg Jul 2 at 9:49 .trim() Possible duplicate of How to escape special characters in building a JSON string? – Islam Elshobokshy Jul 2 at 9:51 JSON.stringify("nnn").slice(1, -1) – Keith ...