DEV Community

Discussion on: An Algorithm to Swap Two Variables Synchronously, Without Creating a Temporary Variable

Collapse
 
ninofiliu profile image
Nino Filiu

js too

[a, b] = [b, a]
Enter fullscreen mode Exit fullscreen mode
Collapse
 
goodevilgenius profile image
Dan Jones

PHP, too.

[$a, $b] = [$b, $a];
Enter fullscreen mode Exit fullscreen mode