I've noticed something weird. I've always thought new Array() was the same as {}, however it seems to be different as {} seems to just be an object type whereas new Array() is an Array in the Chrome debugger.
So I've been using $.param(data), where data is the data from a $.ajax() call. I notice that when i have a params1 = new Array() and a params2 = {} inside the data, they come out differently.
params1 becomes
params1[]=1¶ms1[]=2
and params2 becomes
params2[0]=1¶ms2[1]=2.
The problem is that I had been using .param(data, false) because I noticed that params1[] was being serialized incorrectly, however .param(data, false) fails for params2 and gives me params2=[object+Object].
I figure I can get around this by just using .param(data) and stripping out "[]" so that regardless of it being initialized using {} or new Array, it'll still work out correctly. But I'd like to know if there's a better solution (short of always using {} vs new Array).
[]is shorthand for creating a new JavaScript array, not{}. As you already saw,{}creates an empty object.