QUOTE (Synook @ Sep 18 2009, 08:30 AM)

Don't know about the "JSON is faster" thing - benchmark anyone?
I ran the following code on my Mac (2.4GHz). Two tests are available. Just bloop out one or the other. (Yes, it could be more elegant, but it gets the job done.)
CODE
function trial () {
var d1 = new Date();
for (var i = 0; i < 100000; ++i) {
var arr = new Array ("apple", "frog", "semester", "trio", "bootjack", "leopard", "earthquake", "computer", "liquifaction", "addressee");
// var arr = ["apple", "frog", "semester", "trio", "bootjack", "leopard", "earthquake", "computer", "liquifaction", "addressee"];
delete arr;
}
var d2 = new Date();
var elapsed = (d2.getTime() - d1.getTime()) + " milliseconds";
document.getElementById("results").innerHTML = elapsed;
}
Basically, I created and destroyed 100,000 arrays in each run. I ran about a dozen trials each time. I tested the 2 most popular Mac browsers. Each browser was the latest update.
On Firefox, each method hovered around 28 ms. Very little variation, with no noticeable difference between the array constructor technique and the JSON technique. Yes, I could run 100,000 trials of 100,000 trials and do the math and maybe there would be a difference you could notice. But why bother?
This part is interesting. I ran the same trials on Safari. The JSON technique took roughly 100 ms longer (just under 400%) than it did on Firefox. So the variation between browsers was significantly greater than the variation between Firefox techniques. BUT: the variation on Safari was also large. The times running the JSON technique hovered around 130ms. The times running the constructor technique hovered around 98 ms.
To sum it up: On Firefox, there was no significant difference between techniques. On Safari there was a 32% difference between the techniques, the constructor method being the faster.
Even so, the difference between browsers (400%) was greater still.
FWIW, I get the same results when the array is nullified (instead of deleted and created again).
I'm curious to see results on Windows, including IE7-8. (I'm at work now, and my Windows machine is home.)