Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Swap values with array destructuring

let a = 1, b = 2
[a, b] = [b, a]
console.log(a) // -> 2
console.log(b) // -> 1
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Swap #values #array #destructuring
ADD COMMENT
Topic
Name
2+9 =