4 ms·
It's interesting that Google and jQuery seem to disagree on this as per: http://docs.jquery.com/JQuery_Core_Style_Guidelines#Strings http://docs.jquery.com/JQue
by taitems 15y ago
It's interesting that Google and jQuery seem to disagree on this as per: http://docs.jquery.com/JQuery_Core_Style_Guidelines#Strings http://docs.jquery.com/JQuery_Core_Style_Guidelines#Strings
I'm yet to see a compelling argument for either. My original paragraph for string creation forgave C style strings, as they do seem very clean cut and easy to identify. I think this is an area that needs some debate.
- fuzionmonkey 15y agoI think the idea is that if you use single quotes for strings, you don't have to escape the double quotes that are often found in html. '<p id="foo">something</p>' But the same goes for something like "you can't do that" I guess it just depends what you don't want to escape. For Google, the more probable scenario was probably the former.
- julian37 15y agoThe former isn't a very good reason: HTML/XML accept both double and single quotes, so "<p id='foo'>something</p>" would work equally well.
- joshontheweb 15y agoyes, but it is much more common for double quotes to be used in html
- roel_v 15y agoSingle quotes are not 'C-style strings'. The article is wrong on strings in C. In C, strings and characters are different things (well actually, strings don't even really exist - they are pointers to the beginning of a char-array). So you can say char a1 = 'a'; and char* a2 = "a"; and they're very different things; for one, a2 has a terminating zero. (meaning: the first influences only the contents of a single byte, the second one two, leaving aside alignment). In C: single quote = character, double-quote = easy initialization of array of characters terminated with \0. (the above contains many simplifications, of course)