In principle can know, unshift efficiency is low. Reason is that every add an element, all want to put the existing elements to move down one position. But what efficiency differences have how old? To test the below.
the main hardware test environment: CPU T7100 (1.8 G). The memory of 4 g DDR2 667; Hard disk 5400 RPM. Main software: the operating system to Windows 7; For the Firefox browser 3.6.9. The test code:

var arr=[], s=+ new Date;

//push performance test for (var I=0; I <50000; i++) {
arr. Push (I); .

} the console log (+ new Date -s);
s=+ new Date;
arr=[];

//unshift performance test for (var I=0; I <50000; i++) {
arr. Unshift (I); .

} the console log (+ new Date -s);

this code respectively carried out 50000 times push and unshift operation, running after a time, the results:


1152 12 visible, unshift roughly 100 times slower than a push! Therefore, and be careful at ordinary times the unshift, especially for large arrays. What if must achieve the result of unshift, there is no other method? The answer is yes.
Array has a method, called reverse to the inversion of an Array. To put to in the first array element with a push to add, and then perform a reverse, to reach the effect of unshift. For example:

the for (var I=0; I <50000; i++) {
arr. Push (I);

} arr. Reverse ();

the reverse of what performance, to test again below:

var arr=[], s=+ new Date;
the for (var I=0; I <50000; i++) {
arr. Push (I);

} arr. Reverse (); .
the console log (+ new Date -s);

result:

12, reverse high performance, even without additional consumption, can be at ease use.


This concludes the body part