余計な変数を使わないスワップ
var a = 0;
var b = 1;
console.log(a, b); // 0 1
a = [b, b = a][0];
console.log(a, b); // 1 0
Go to list of users who liked
More than 5 years have passed since last update.
余計な変数を使わないスワップ
var a = 0;
var b = 1;
console.log(a, b); // 0 1
a = [b, b = a][0];
console.log(a, b); // 1 0
Register as a new user and use Qiita more conveniently
Go to list of users who liked