How to swap 2 variables in javascript

Marco Pestrin
Jan 12, 2021

Normally to swap two variables you need a temporary variable because when the first variable is reassigned you lose the value.

We have the syntax available to perform a swap without need an intermediate variable.

Javascript destructuring enable variable swapping without need an intermediate variable.

Cheers mates!

--

--