This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function repeatStringBinary(str, how_many) | |
{ | |
how_many|=0; // convert to number and round | |
str+=""; // convert to string | |
if(how_many<=0 || str.length==0) | |
return ""; | |
if(how_many==1) | |
return str; | |
if(how_many==2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function repeatString(str, how_many) | |
{ | |
how_many|=0; // convert to number and round | |
str+=""; // convert to string | |
if(how_many<=0 || str.length==0) | |
return ""; | |
if(how_many==1) | |
return str; | |
if(how_many==2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sorry. Hack fail :( | |
// "Speedup" in opera and chrome because bugs in webkit (compile return undefined) | |
// and opera (invalid regexp object return). | |
// Giant thanks to @jdalton and @diegoperini | |
var i,n=20000; | |
var i=0; | |
var t=""; | |
for(i=0;i<10000;++i) | |
t+=" a"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i,n=300000; | |
var d0=new Date().getTime(); | |
for(i=0;i<n;++i) | |
"1.5"-0; | |
alert("-0: "+(new Date().getTime()-d0)+" ms"); | |
var d0=new Date().getTime(); | |
for(i=0;i<n;++i) | |
+"1.5"; |
NewerOlder