Ruphaa's Notes
← Go Back
How to swap variables using array destructuring in JS
js
let
x
=
2
;
let
y
=
3
;
[
x
,
y
]
=
[
y
,
x
]
;
console
.
log
(
x
)
;
// 3
console
.
log
(
y
)
;
// 2