1. Swapping Values Without a Temporary Variable
This one-liner uses array destructuring to swap the values of
a
and
b
without needing a temporary variable. It's a neat trick that makes your code cleaner and more concise. The
[a, b] = [b, a]
syntax swaps their values by destructuring the array on the right-hand side and assigning it to the left-hand side.
testing...