Trivial Question About Quotes

P

philmasterplus

When JavaScripting, I've often seen strings wrapped with single-
quotes:
----------------------------------------------------------------
var language = 'English';
----------------------------------------------------------------

However, I prefer double-quotes due to my experience with C++:
----------------------------------------------------------------
var language = "English";
----------------------------------------------------------------

Is there a problem with this? Why is everyone else, including those
who write popular libraries like Prototype.js, using single-quotes? I
know that it's best to stick to a single style when you code(that is,
if your coding style isn't horrible), but is using double-quotes
horrible? Or is it just because you want to use double-quotes inside
strings? :
 
B

Bjoern Hoehrmann

* philmasterplus wrote in comp.lang.javascript:
When JavaScripting, I've often seen strings wrapped with single-
quotes:

There can be a variety of reasons. For example, on some keyboards the
apostrophe is easier to enter (e.g., you might not have to press shift);
in some programming languages variables and most escaped sequences are
interpolated and recognized in "-literals but not in '-literals; quot is
easily confused with two apos characters in some environments; some may
have a convention like `" for markup attributes, ' for script code` so
they avoid misnesting them in onclick="...'...'..." attributes, or their
native language might be using some kind of single quote mark so they
are more used to them. And so on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top