DEV Community

Discussion on: How can you swap two variables without using a third?

Collapse
 
dhilipkmr profile image
Dhilip kumar

If there are two variables a and b we could destructure them.

var a = 12;
var b = 21;
[a, b] = [b, a];

Values are interchanged :)