[Javascript] Single vs. Double quotes in Javascript

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Nov 13 10:00:14 CST 2003



>I did not test this code to confirm or deny the 15% faster claim

I did, and cannot confirm it. It seems that single quotes are *sometimes* 
faster in Explorer Windows (roughly 1/3 of my tests did show a faster 
response time), but if Mozilla shows a difference at all, it handles double 
quotes slightly faster. I found no difference at all in Opera.

I cannot say that these experiments confirm the 15% claim.

>-------
>var s='';
>var iTime1 = new Date().valueOf();
>for(var i=0;i<100000;i++){
>	s+="a";
>}
>var iTime2 = new Date().valueOf();
>alert('With double quote : ' + (iTime2 - iTime1));
>
>
>s='';
>iTime1 = new Date().valueOf();
>for(var i=0;i<100000;i++){
>	s+='a';
>}
>iTime2 = new Date().valueOf();
>alert('With single quote : ' + (iTime2 - iTime1));
>-------

-------------------------------------------------------------------
ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
http://www.quirksmode.org/
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
------------------------------------------------------------------

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the Javascript mailing list