Skip to content

Commit 2ffb7b7

Browse files
Swap as destructuring assignment (trekhleb#497)
1 parent 194f213 commit 2ffb7b7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/algorithms/sorting/insertion-sort/InsertionSort.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export default class InsertionSort extends Sort {
2121
this.callbacks.visitingCallback(array[currentIndex - 1]);
2222

2323
// Swap the elements.
24-
const tmp = array[currentIndex - 1];
25-
array[currentIndex - 1] = array[currentIndex];
26-
array[currentIndex] = tmp;
24+
[array[currentIndex - 1], array[currentIndex]] = [array[currentIndex], array[currentIndex - 1]];
2725

2826
// Shift current index left.
2927
currentIndex -= 1;

0 commit comments

Comments
 (0)