I wouldn't say that's any worse, especially in this scenario. But they should get it just as quickly.
Edit: trim the string. :)
I wouldn't say that's any worse, especially in this scenario. But they should get it just as quickly.
Edit: trim the string. :)
Edit: Not tested myself. I had a suspicion about it and "confirmed" it via an older post that is perhaps outdated now. Updated this comment to sound less authoritative ("I would think").
On my machine, I was surprised to see that the for loop is the fastest (Chrome + Crunchbang).
I'd guess that this is probably because looping structures are heavily optimized in modern JS engines.
Basic things like caching DOM lookups are always good, but not so much the little things.
Edit: Apparently the loop is faster.[0] :)
Fixed: http://jsperf.com/spacify/4