Single quotes are best when you want to use double quotes within your string, as using a double quote within a string (without escaping it) will end it. The opposite is also true, so you can use single quotes within a set of doubles.
Apart from that theres no "real terms" difference as they both perform the same function.
Hi all.
What's a good practice on using 'single' and "double" quotes on a Javascript/jQuery script? Like when and where to use each?
Thanks.
Single quotes are best when you want to use double quotes within your string, as using a double quote within a string (without escaping it) will end it. The opposite is also true, so you can use single quotes within a set of doubles.
Apart from that theres no "real terms" difference as they both perform the same function.
According to the JQuery style guide though, double quotes should always be used for strings (http://docs.jquery.com/JQuery_Core_Style_Guidelines)
As Andy has mentioned, it really comes down to personal preference.
While I know you are asking specifically about JS, keep in mind that there is a difference sometimes in PHP.
...all the time. just not always a different outcome : )