Remember those years of sorting temp? It’s time to get some fresh blood. Code up.

  // Destruct the assignment exchange
  let small=66,big=88;
  [small,big]=[big,small];
  
  // add and subtract swaps
  small=99,big=1000;
  small=small+big;
  big=small-big;
  small=small-big;
  
  // XOR operation swap, because the underlying use of binary xOR operation, the best effect
  small=11,big=22;
  small=small^big;
  big=small^big;
  small=small^big;

Copy the code

Break out of the rut and make your code shine!

For those interested in deconstruction assignment, see: MDN Deconstruction Assignment

If you feel useful, praise up your recognition, is my writing strong power welcome everyone comments, give valuable advice :)Copy the code