Trivial Question About Quotes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • philmasterplus

    Trivial Question About Quotes

    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? :
    ----------------------------------------------------------------
    var example = 'She says, "Hello, world!"';
    ----------------------------------------------------------------

    I know this is a trivial question, but please give me as much
    details as possible...^^;;
  • Bjoern Hoehrmann

    #2
    Re: Trivial Question About Quotes

    * philmasterplus wrote in comp.lang.javas cript:
    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?
    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.
    --
    Björn Höhrmann · mailto:bjoern@h oehrmann.de · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

    Comment

    Working...