1 2 3 |
let a = 10, b = 20; [a, b] = [b, a]; console.log(a, b); // => 20, 10 |

Skip to content
# Welcome to O(n^2)

## Comprehensive notes of a lifelong learner

# Swapping 2 variables’ values in one line

1 2 3 |
let a = 10, b = 20; [a, b] = [b, a]; console.log(a, b); // => 20, 10 |