6

Possible Duplicate:
When to Use Double or Single Quotes in JavaScript
Difference between single quotes and double quotes in Javascript

I searched this website and google (in that exact order...) looking for:

Are there any differences between ' and " regarding to strings in Javascript\ JQuery?

Didn't find a thing...

Community
  • 1
  • 1
gdoron
  • 147,333
  • 58
  • 291
  • 367

3 Answers3

9

As long as you pair them properly there is no difference.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
  • 1
    There's quite an important difference: Within a double-quote-delimited string literal (`"foo"`), you can't use a double quote (`"`) without escaping it (`\"`); within a single-quote-delimited string literal, you can. Similarly, within a single-quote-delimited string literal (`'foo'`), you can't use a single quote (`'`) without escaping it (`\'`); within a double-quote-delimited string literal you can. There's no difference in the *resulting strings*, but there's a big difference in the string literals. – T.J. Crowder Feb 21 '18 at 10:08
2

No, there's no difference at all. It's a matter of personal preference.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

Can be used interchangeably in terms of jquery selectors. Once one is chosen for enclosing selector string, then inner quotes will use the "other one", or perhaps be escaped.

ek_ny
  • 10,153
  • 6
  • 47
  • 60
  • Can you please give an example? – gdoron Jan 23 '12 at 16:20
  • A little out of time, but it may help another person. Example: `var string1 = 'Einstein said: "A person who never made a mistake never tried anything new."'; var string2 = "Einstein said: \"A person who never made a mistake never tried anything new.\"";`. If you output both variables, the resulting string is exactly the same – davidaam May 06 '12 at 04:21