Grow your CSS skills. Land your dream job.

single/double quotes

  • # November 29, 2012 at 8:03 pm

    Hi all.

    What’s a good practice on using ‘single’ and “double” quotes on a Javascript/jQuery script?
    Like when and where to use each?

    Thanks.

    # November 29, 2012 at 8:08 pm

    Single quotes are best when you want to use double quotes within your string, as using a double quote within a string (without escaping it) will end it. The opposite is also true, so you can use single quotes within a set of doubles.

    Apart from that theres no “real terms” difference as they both perform the same function.

    According to the JQuery style guide though, double quotes should always be used for strings (http://docs.jquery.com/JQuery_Core_Style_Guidelines)

    # November 29, 2012 at 8:33 pm

    As Andy has mentioned, it really comes down to personal preference.

    While I know you are asking specifically about JS, keep in mind that there is a difference sometimes in PHP.

    __
    # November 29, 2012 at 11:44 pm

    > While I know you are asking specifically about JS, keep in mind that there is a difference sometimes in PHP.

    …all the time. just not always a different outcome : )

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".