Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript double or single quotes?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #37554
    aoeui
    Participant

    once read tutorial regarding usage of quotes in .js
    cannot find it again

    is it better to use “something” or ‘something’
    while writing .js ?

    #100858
    Senff
    Participant

    I wouldn’t say it’s better (or worse) than anything, but the standard way seems to be using single quotes in code, so you can use double quotes when writing out HTML code, if needed.

    document.write('
    ');

    #100860
    jamygolden
    Member

    I’m not too sure, you could say it the other way round too:

    $('
  • ', {
    text: "Don't click here"
    });

    the single quote will be closed-off by the single quote used in “don’t”.

    I don’t think it matters at all. I know people who use double and single quotes. I use single quotes because it looks neater to me.

    #100867
    Mottie
    Member

    The only exception I can think of is within JSON… everything must be in double quotes.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.