Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Jane Volin4,193 Points
What is the difference between using single or double quotes around a statement?
It seams like they serve the same purpose. I recently completed the code academy java script course and they use single quotes throughout their script. Just curious about what is the best practice and why?
Nick Yoho6,957 Points
It depends how you use it, but they do the same thing. A double quote surrounding a string that has a word containing an apostrophe in it will work normally. If you have single quotes around the same string you will get an error unless you add a \ within the word with the apostrophe (that\'s) to escape it.
Jason AndersTreehouse Moderator 145,826 Points
Like Nick has said, there is no difference. It really is personal preference, just remain consistent in your code.
Just an additional note... with some languages (i.e. PHP), double quotation marks act differently than single quotation marks, and using one instead of the other could break you code. But for the most part (and most languages) it really is just a preference.