View Full Version : Single vs Double Quotes??
Grimsk
28 Aug 2007, 9:16 AM
any advantage in JS one vs other?
jon.whitcraft
28 Aug 2007, 11:52 AM
Not sure I follow what you are asking... can you please explain more
pyrolupus
28 Aug 2007, 11:53 AM
I don't think there is a performance or legibility benefit. Personally, I got used to normally using single quotes ('), because it's more efficient in PHP. (Single quoted strings in PHP--and Perl--are not interpolated. This grants a slight performance boost by single-quoting when no interpolation is needed.)
A nice side-effect of this habit is that it is uncommon that I need to worry about changing my HTML attributes or JS quoting when hooking up events, either directly in HTML or when outputting client-side script from my server code (which makes this habit a good one even when working in ASP.Net).
Pyro
Edit: I believe Grimsk is asking about quoting strings with single quotes versus double quotes. That was the nature of my answer. @Grimsk: If I'm wrong, then disregard the above. ^_-
Grimsk
28 Aug 2007, 1:29 PM
thnks pyrolupus its exactly what i asked ;) sorry for my bad english!
christocracy
28 Aug 2007, 9:04 PM
var I_USE = '<p class="single-quotes">so I can use double-quotes for HTML element attributes.</p>';
Animal
28 Aug 2007, 11:53 PM
Yes, I use double quoutes for HTML attribute, so single for javascript code.
It gets complex though when you're writing a Java tag handler which generates javascript which specifies an Ext Template string.
Then try coding the template string in a JSP page!!!!
Grimsk
29 Aug 2007, 3:47 AM
it would be good in the core of ext. to always use same convention ..?!
mystix
29 Aug 2007, 4:04 AM
it would be although in the core of ext. to always use same convention ..
:-/
jack.slocum
30 Aug 2007, 3:57 AM
it would be good in the core of ext. to always use same convention ..?!
My preference is single quotes. However, at various times (usually before a major release) I go through and change everything to double quotes. The reason is double quotes "pack" without an escape char, unlike single quotes resulting in a better compressed file size.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.