0
how can I exchange the value of 2 variables without using a third one, in Javascript, thanks
3 odpowiedzi
+ 5
In ES6, you can use array destructuring. Example
let a = 1
let b = 2
[a, b] = [b, a]
console.log(a - b) //outputs 1 (2 - 1)
+ 1
It is quit simple
var a = 10;
var b = 20;
[a,b]=[b,a]
console.log(a,b);
See this
0
thanks, for me the best solution is destructuring array