mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 23:21:18 +08:00
Swap as destructuring assignment (#497)
This commit is contained in:
parent
194f2133af
commit
2ffb7b7abf
@ -21,9 +21,7 @@ export default class InsertionSort extends Sort {
|
||||
this.callbacks.visitingCallback(array[currentIndex - 1]);
|
||||
|
||||
// Swap the elements.
|
||||
const tmp = array[currentIndex - 1];
|
||||
array[currentIndex - 1] = array[currentIndex];
|
||||
array[currentIndex] = tmp;
|
||||
[array[currentIndex - 1], array[currentIndex]] = [array[currentIndex], array[currentIndex - 1]];
|
||||
|
||||
// Shift current index left.
|
||||
currentIndex -= 1;
|
||||
|
Loading…
Reference in New Issue
Block a user