Reputation: 18541
Logging JSON or HTML strings in the Chrome console is nice because there's few escape strings and it's both easily readable and copyable:
> JSON.stringify({ a: 'b' })
< "{"a":"b"}"
> '<div class="square">'
< "<div class="square">"
The node REPL is even better, because it logs syntactically correct content:
> JSON.stringify({ a: 'b' })
'{"a":"b"}'
> '<div class="square">'
'<div class="square">'
Chrome's "{"a":"b"}"
is not a valid JS string, but Node's '{"a":"b"}'
is.
Firefox however, uses double quotes when logging strings, and escapes the double quotes characters, so its logs are valid JS, but are neither easy to read not copyable.
> JSON.stringify({ a: 'b' })
< "{\"a\":\"b\"}"
> '<div class="square">'
< "<div class=\"square\">"
I'd like to configure the Firefox devtools to use single quotes when logging strings, just like Node does, is there a hack for that?
I am aware of this bugzilla issue on the subject, but it's 3 human years old (aka 30 internet years old), and no one has been assigned to this issue, but perhaps there is a hidden configuration that can be done.
Upvotes: 1
Views: 163
Reputation: 20125
With linking to the related Bugzilla issue you already gave the answer yourself.
In there, one of the developers wrote that he'd rather not add a preference to control this. So that means there is currently no way to change that, unfortunately.
I've also dug through the DevTools code, and indeed the double quotes in strings are currently (as of Firefox 84) hard coded.
So the best way forward here is by commenting on the issue and describing your use case.
Upvotes: 1