code :
JSON.parse('{"a":"\\\\"}');
node: { a: '\\' }
chrome: {a: "\"}
Why it behaves different between Node and Chrome? I've check the v8 version of them and both are 5.x, it's weird.
It's just a difference in the presentation of the object contents by the console implementations. If you do
console.log(JSON.parse('{"a":"\\\\"}').a.length)
in both environments you correctly get 1
.
The Node console seems to want to show you the object contents such that you could re-create the object with cut-and-paste. The Chrome console just shows the single backslash, but there's just one backslash for real in both environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With