From: dhtml on 3 Aug 2010 04:13 On Aug 3, 1:12 am, dhtml <dhtmlkitc...(a)gmail.com> wrote: > On Jul 30, 7:45 am, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote: > [...] > have newsreader setup on this machine. I do not like GG and I think I > may have just posted "c" by accident. Confirmed. -- Garrett
From: Asen Bozhilov on 3 Aug 2010 05:00 dhtml wrote: > It's fine, but why do you think this is better or do you think the FAQ > should use this instead? Both versions are good. I posted my code, just for give another alternative for people who read the FAQ entries. I am not pretended for my version is better than FAQ code. In my version I do not use three time string concatenations plus three invocation of `slice' method. I am just using mathematical operation plus `replace' which I suppose is faster than than version used by FAQ.
From: Lasse Reichstein Nielsen on 4 Aug 2010 12:16 dhtml <dhtmlkitchen(a)gmail.com> writes: > On Jul 30, 7:45 am, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote: >> return (yyyy + "-" + mm + "-" + dd).replace(/\b1/g, ''); I think RegExp replace is a little heavy-duty for something like this. How about return String(yyyy).substring(1) + "-" + String(mm).substring(1) + "-" + String(dd).substring(1); ? /L -- Lasse Reichstein Holst Nielsen 'Javascript frameworks is a disruptive technology'
From: Asen Bozhilov on 5 Aug 2010 04:54 Lasse Reichstein Nielsen wrote: > I think RegExp replace is a little heavy-duty for something like this. Indeed. I had to test in various implementations. I tested my approach in Rhino 1.7 under Debian 5.0 and was faster than FAQ. From tests provided by Dr J R Stockton and mines FAQ approach is faster than my. Do you have explanation why? I am still thinking RegExp approach should be faster than three string concatenation + three invocations of `slice'. > How about > return String(yyyy).substring(1) + "-" + > String(mm).substring(1) + "-" + > String(dd).substring(1); > ? Btw, I used similar version before I post RegExp approach. Do you have any reasons to use `substring' instead of `slice'?
First
|
Prev
|
Pages: 1 2 Prev: FAQ Topic - What does the future hold for ECMAScript? (2010-07-20) Next: trying to do AJAX |