-1

In jQuery, what is difference between using two single quotes for a string and using two double quotes for a string.

alert('I am using single quotes');
alert("I am using single quotes");

I see the same output for both.

j08691
  • 204,283
  • 31
  • 260
  • 272
Kurkula
  • 6,386
  • 27
  • 127
  • 202

2 Answers2

1

There is no difference. You can use the one you prefer, as long as you're consistent about it.

I personally prefer using double quotes so I don't have to escape as much.

var a = 'I\'ve got O\'Hara and O\'Reilly coming.';
var b = "You've got absolutely nobody, O'Mallon!";
Wander Nauta
  • 18,832
  • 1
  • 45
  • 62
1

Convenience. If you have a string containing a single quote, you can use double quotes to wrap it without needing an escape character or vice versa.

Chris Ballard
  • 3,771
  • 4
  • 28
  • 40