2012-09-07 28 views

回答

1
var arr = ['one', 'two', 'three'], 
    temp; 

temp = arr[1]; // temp is 'two' 
arr[1] = arr[0]; // Now it is ['one', 'one', 'three'] 
arr[0] = temp; // And now it is ['two', 'one', 'three'] 

只需使用一個臨時變量。

Demo

+0

它比我想象的要容易) –