[Javascript] Single vs. Double quotes in Javascript
liorean
liorean at f2o.org
Fri Nov 14 09:05:32 CST 2003
HÕkan Magnusson wrote:
>> And the test:
>> javascript:var a=50,b=[];while(a--)b.push((function(){var i=new
>> Date,t=5e4,s='';while(t--)s+='text';return (new
>> Date-i);})());while(b.length>1)b[0]+=b.pop();b/=50; // Substitute
>> single for double quotes to get the double quote test
>>
>> (I tried to run the test code in ie6w and saf1.0 both, but the
>> browsers just stopped responding each time I did that, so I have no
>> test results from there...)
I let both run while I went on a two hour lecture.... They were still
not finished when I came home...
> It doesn't stop, actually.
Well, that's what makes them not respond. Moz dies the same while it
executes, but with the difference that it finishes the
> But Moz is *billions* (he he) times faster than IE on these string operations, and you get the impression that IE hangs. Just wait it out, if you want to see some really sad performance.
Wait it out? I don't want a program to consume 100% CPU while I'm trying
to use the computer!
> I stand corrected regarding the single versius double quote performance
> claim. Sorry about that, I'll check my sources better the next time.
Heh. Some scripting languages see a difference between single qouted and
double qouted strings. For example, in Ruby double quoted strings are
parsed, which means that program entities and such within them are
replaced with their values. That makes a speed difference.
> I still want to know the "true" difference between single and double
> quotes, though. If any.
There is none in JavaScript. Consort with the DevEdge JavaScript 1.5
Core Guide if you want confirmation, or if that doesn't explain it in
detail, have a look at "7.8.4 String Literals" in ECMA-262 3ed.
<http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/ident.html#1008368>
<http://www.mozilla.org/js/language/E262-3.pdf>
--
liorean <mailto:liorean at user.bip.net>
ViewStyles, ViewScripts, ToggleStyles and GraphicsInfo bookmarklets and
Theme Switcher, Cookies Handler scripts:
<http://liorean.web-graphics.com/>
More information about the Javascript
mailing list