-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
  • 197,815
  • 30
  • 248
  • 265
Kurkula
  • 6,945
  • 26
  • 108
  • 186

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
  • 16,681
  • 1
  • 41
  • 60
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,741
  • 4
  • 27
  • 40