Real parameter restrictions of JavaScript Functions.
I vaguely remember what I have mentioned in this book that the actual parameter limit is 32? Now I guess it's wrong. He might be talking about 32-bit. Test results:
Safari contains 65535. That is, ushort is used for storage (2 bytes, 16 bytes, and 1). For more information, ignore.
Other browsers are at least Int. maxvalue. It is said that Firefox or even long is used to maintain real parameters. Other browsers may be Int or uint. This doesn't matter. After all, we know that the bottleneck is 65535.
Based on the above basics, you can use []. Push. Apply (A, B) to replace a = A. Concat (B ); We only need to note that for Safari, the length of B cannot exceed 65535. The problem with Concat is that the new array is generated, the arrays A and B are traversed, and the elements A and B are placed in order.
TestCode: var COUNT = 100000, A = [1, 2, 3], B = [4, 5, 6], r = [], I, D;
d = new date;
for (I = count; I --;) {
. concat (B);
}< span>
r [0] = new date-D;
d = new date;
for (I = count; I --;) {
r. push. apply (a, B);
// A = [1, 2, 3];
}< span>
r [1] = new date-D;
alert (r);
it can be concluded that even the push of an old browser like IE6 chrome2 Safari 3 Firefox 2 is perfect, even if some browsers are removed // A = [1, 2, 3]; comments section. the efficiency is better than Concat. such as chrome7 Dev and Safari 5.