ES2015の機能を使うとシンプルに書ける。
> let x = 2, y = 3;
undefined
> [x, y] = [y, x] # ここ
[ 3, 2 ]
> x
3
> y
2
More than 3 years have passed since last update.
ES2015の機能を使うとシンプルに書ける。
> let x = 2, y = 3;
undefined
> [x, y] = [y, x] # ここ
[ 3, 2 ]
> x
3
> y
2
Register as a new user and use Qiita more conveniently