Skip to content

www.leonenkov.ru

Comprehensive notes of a lifelong learner

  • Home
  • Author

Swapping 2 JS variables’ values in one line

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