Search code examples
javascriptjquerystringquotessemantics

Is there a interpretation difference between "..." and '...'?


All coding "tutorials" I've used so far use single quotes (' '), but they need to escape apostrophes using a \. So I've switched to use double quotes (" ") because they work just as well without the need to escape special punctuation signs.

Is there a difference how JavaScript or jQuery interprets the string depending on the type of quote I use? Is there a speed or possible syntax issues with using one over another?


Solution

  • They are the same. But your statement:

    So I've switched to use double quotes because they work just as well without the need to escape special punctuation signs.

    is incorrect, because you must escape double quotes too when used in a string, for example:

    quote = "\"The early bird gets the worm\""
    

    If you want to avoid this, use a combination of both:

    quote = '"The early bird gets the worm"'