Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Lines changed: 1 addition & 3 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /