News for hackers. Stuff that matters.
Re:Airbnb JavaScript Style Guide by NhanH on Friday July 03, 2015 @01:18AM (#9823655)
If JSON requires the string to be double-quoted, then it's more convenient to use singe quotes, since your embedded JSON string (if you ever used it) won't need to have its quotes escaped.
Re:Airbnb JavaScript Style Guide by elisee on Friday July 03, 2015 @01:22AM (#9823667)
Interesting. Is that common in your workflow to embed JSON as string literals in JavaScript? Never had to do that. I'd probably use ES6 backticks, so as to have multiline support and skip the need to escape both single and double quotes.
Re:Airbnb JavaScript Style Guide by adrusi on Friday July 03, 2015 @01:52PM (#9826940)
Right, why write

    '{ "foo": "bar" }'
when you could write

    JSON.stringify({ foo: "bar" })
and get a static guarantee of valid JSON?