The following code example shows unexpected behavior of `replace` method:

```js
let str = "some long string\nwith line\nbreaks"
console.log(str.replace(/\n/g,''))
str = JSON.stringify(str)
console.log(str.replace(/\n/g,''))
```

I see that there are some warnings about the usage of `JSON.stringify` in the [documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#issue_with_plain_json.st%5B%E2%80%A6%5Dify_for_use_as_javascript) and there is a seven-years-old discussion of similar issues [here](https://esdiscuss.org/topic/string-prototype-replace-problems-with-json-stringify-and-serialization-of-objects).

What exactly does `JSON.stringify` do to the string that the replace does not work the same way?