0
,比如我有一個數組var arr = ['one', 'two', 'three'];
我wona更換1關鍵2日,我的陣列應該開始看起來像['two', 'one', 'three'];
我該怎麼做,它需要我爲泡沫排序
,比如我有一個數組var arr = ['one', 'two', 'three'];
我wona更換1關鍵2日,我的陣列應該開始看起來像['two', 'one', 'three'];
我該怎麼做,它需要我爲泡沫排序
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']
只需使用一個臨時變量。
它比我想象的要容易) –