Swap two variables in one line? #javascript #typescript #swap #tipsandtricks #tamslab #tam11a

preview_player
Показать описание
Instead of using a temporary variable, try with array destructuring, [a, b] = [b, a]. You can instantly swap a and b. No temporary variable needed!

It’s fast, it’s clean, and it works perfectly.

Enjoyed this tip? Hit like and subscribe for more JavaScript, TypeScript shortcuts. See you in the next one!
Рекомендации по теме
Комментарии
Автор

Dang. I was looking for it. It helped a lot. Thanks❤

qaviuno
welcome to shbcf.ru