views:

140

answers:

4

I know that in PHP the only difference between double quotes and single quotes is the interpretation of variable inside a string.

Well, in jQuery Javascript, I often see doublequotes used in jQuery selectors, or in strings, is there a particular reason for that or is single quotes just the exact same as doublequotes?

+3  A: 

Absolutly no difference. FREE QUOTING YEEHHAAA

jAndy
Thanks for the quick answer ;) Will accept asap
Michael Lumbroso
@Michael: liarrr :p
jAndy
Sorry I accepted your answer at first, but found karim better after all ;) hope you don't mind
Michael Lumbroso
A: 

They are the same, I usually use single quotes but thats because I am a .net developer and asp.net in particular so it aids me in distinguishing between the 2 types of strings.

Pharabus
why a downvote?
Pharabus
+7  A: 

You'll want to use single quotes where you want double quotes to appear inside the string (e.g. for html attributes) without having to escape them, or vice versa. Other than that, there is no difference.

karim79
A: 

There is a difference in JSON, so I have started switching to using double-quotes as much as possible so that I don't make mistakes when dealing with JSON.

Jesse Brown
Personally, I think it's much better not to try to read and write JSON yourself. I always JSON.parse and JSON.stringify, so that I'm free to use single quotes, double quotes, or even no quotes, without worrying about causing parse errors elsewhere.
MatrixFrog