Skip to content

Welcome to O(n^2)

Comprehensive notes of a lifelong learner

  • Home
  • Author

Swapping 2 variables’ values in one line

24.01.202124.01.2021 ~ Roman
1
2
3
let a = 10, b = 20;
[a, b] = [b, a];
console.log(a, b); // => 20, 10
Posted in JavaScript Tricks

Post navigation

< Previous Handy JS in operator
Next > Use Datalist tag to provide autocomplete options for Input field