mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-27 15:41:16 +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]);
|
this.callbacks.visitingCallback(array[currentIndex - 1]);
|
||||||
|
|
||||||
// Swap the elements.
|
// Swap the elements.
|
||||||
const tmp = array[currentIndex - 1];
|
[array[currentIndex - 1], array[currentIndex]] = [array[currentIndex], array[currentIndex - 1]];
|
||||||
array[currentIndex - 1] = array[currentIndex];
|
|
||||||
array[currentIndex] = tmp;
|
|
||||||
|
|
||||||
// Shift current index left.
|
// Shift current index left.
|
||||||
currentIndex -= 1;
|
currentIndex -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user